git-pivotal 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,14 @@
1
+ v 0.1.3
2
+ - Fixed bug preventing command line args from being properly interpretted
3
+
4
+ v 0.1.2
5
+ - Fixed bug introduced in v 0.1.1 which prevented git pick from completing
6
+
7
+ v 0.1.1
8
+ - Updated git pick to tell Pivotal who owns the picked feature
9
+ - Improved Pivotal Tracker framework write ability
10
+
11
+ v 0.1.0
12
+ - Initial release
13
+ - Basic framework for reading from Pivotal Tracker
14
+ - git pick utility
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/git-pick CHANGED
@@ -5,4 +5,4 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
5
  require 'pivotal'
6
6
  require 'commands/pick'
7
7
 
8
- exit Pick.new.run(*ARGV)
8
+ exit Pick.new(*ARGV).run!
data/git-pivotal.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{git-pivotal}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Tucker"]
12
- s.date = %q{2010-01-29}
12
+ s.date = %q{2010-01-30}
13
13
  s.default_executable = %q{git-pick}
14
14
  s.description = %q{A collection of git utilities to ease integration with Pivotal Tracker}
15
15
  s.email = %q{jeff@trydionel.com}
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  ]
20
20
  s.files = [
21
21
  ".gitignore",
22
+ "CHANGELOG",
22
23
  "LICENSE",
23
24
  "Rakefile",
24
25
  "VERSION",
data/lib/commands/pick.rb CHANGED
@@ -2,7 +2,7 @@ require 'optparse'
2
2
 
3
3
  class Pick
4
4
 
5
- attr_accessor :api
5
+ attr_accessor :options
6
6
 
7
7
  def initialize(*args)
8
8
  @options = {}
@@ -10,23 +10,53 @@ class Pick
10
10
  parse_argv(*args)
11
11
  end
12
12
 
13
- def run
14
- connect_to_pivotal
13
+ def run!
14
+ unless options[:api_token] && options[:project_id]
15
+ puts "Pivotal Tracker API Token and Project ID are required"
16
+ return 1
17
+ end
18
+
19
+ puts "Retrieving latest stories from Pivotal Tracker..."
20
+ api = Pivotal::Api.new(:api_token => options[:api_token])
21
+
22
+ project = api.projects.find(:id => options[:project_id])
23
+ story = project.stories.find(:conditions => { :story_type => :feature, :current_state => :unstarted }, :limit => 1).first
15
24
 
16
- story = find_story
17
- build_feature_branch story
18
- start_story story
25
+ unless story
26
+ puts "No stories available!"
27
+ return 0
28
+ end
29
+
30
+ puts "Story: #{story.name}"
31
+ puts "URL: #{story.url}"
32
+
33
+ suffix = "feature"
34
+ unless options[:quiet]
35
+ print "Enter branch name (will be prepended by #{story.id}) [feature]: "
36
+ suffix = gets.chomp
37
+
38
+ suffix = "feature" if suffix == ""
39
+ end
40
+
41
+ puts "Creating branch..."
42
+ branch = "#{story.id}-#{suffix}"
43
+ create_branch branch
44
+
45
+ puts "Updating story status in Pivotal Tracker..."
46
+ story.start!(:owned_by => options[:full_name])
47
+
48
+ return 0
19
49
  end
20
50
 
21
51
  private
22
52
 
23
53
  def sys(cmd)
24
- puts cmd if @options[:verbose]
54
+ puts cmd if options[:verbose]
25
55
  system cmd
26
56
  end
27
57
 
28
58
  def get(cmd)
29
- puts cmd if @options[:verbose]
59
+ puts cmd if options[:verbose]
30
60
  `#{cmd}`
31
61
  end
32
62
 
@@ -35,56 +65,27 @@ private
35
65
  id = get("git config --get pivotal.project-id").strip
36
66
  name = get("git config --get pivotal.full-name").strip
37
67
 
38
- @options[:api_token] = token if token
39
- @options[:project_id] = id if id
40
- @options[:full_name] = name if name
68
+ options[:api_token] = token if token
69
+ options[:project_id] = id if id
70
+ options[:full_name] = name if name
41
71
  end
42
72
 
43
73
  def parse_argv(*args)
44
74
  OptionParser.new do |opts|
45
75
  opts.banner = "Usage: git pick [options]"
46
- opts.on("-k", "--api-key=", "Pivotal Tracker API key") { |k| @options[:api_token] = k }
47
- opts.on("-p", "--project-id=", "Pivotal Trakcer project id") { |p| @options[:project_id] = p }
48
- opts.on("-n", "--full-name=", "Pivotal Trakcer full name") { |n| @options[:full_name] = n }
49
- opts.on("-q", "--quiet", "Quiet, no-interaction mode") { |q| @options[:quiet] = q }
50
- opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| @options[:verbose] = v }
76
+ opts.on("-k", "--api-key=", "Pivotal Tracker API key") { |k| options[:api_token] = k }
77
+ opts.on("-p", "--project-id=", "Pivotal Trakcer project id") { |p| options[:project_id] = p }
78
+ opts.on("-n", "--full-name=", "Pivotal Trakcer full name") { |n| options[:full_name] = n }
79
+ opts.on("-q", "--quiet", "Quiet, no-interaction mode") { |q| options[:quiet] = q }
80
+ opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| options[:verbose] = v }
51
81
  opts.on_tail("-h", "--help", "This usage guide") { puts opts; exit 0 }
52
82
  end.parse!(args)
53
83
  end
54
84
 
55
- def connect_to_pivotal
56
- unless @options[:api_token] && @options[:project_id]
57
- puts "Pivotal Tracker API Token and Project ID are required"
58
- exit 0
59
- end
60
-
61
- puts "Retrieving latest stories from Pivotal Tracker..."
62
- @api = Pivotal::Api.new(:api_token => @options[:api_token])
63
- end
64
-
65
85
  def agrees?(selection)
66
86
  selection =~ /y/i || selection == ""
67
87
  end
68
88
 
69
- def find_story
70
- project = @api.projects.find(:id => @options[:project_id])
71
- story = project.stories.find(:conditions => { :story_type => :feature, :current_state => :unstarted }, :limit => 1).first
72
-
73
- unless story
74
- puts "No stories available!"
75
- exit 0
76
- end
77
-
78
- puts "Story: #{story.name}"
79
- puts "URL: #{story.url}"
80
- print "Accept this story? (Yn): "
81
- selection = gets.chomp
82
-
83
- exit 0 if !agrees?(selection)
84
-
85
- story
86
- end
87
-
88
89
  def create_branch(branch)
89
90
  unless branch_exists?(branch)
90
91
  puts "Creating #{branch} branch..."
@@ -96,24 +97,4 @@ private
96
97
  !get("git branch").match(branch).nil?
97
98
  end
98
99
 
99
- def build_feature_branch(story)
100
- branch = "feature-#{story.id}"
101
-
102
- puts "Suggested branch name: #{branch}"
103
- print "Accept this name? (Yn): "
104
- selection = gets.chomp
105
-
106
- unless agrees?(selection)
107
- print "Enter new name (will be prepended by #{story.id}): "
108
- branch = "#{story.id}-" + gets.chomp
109
- end
110
-
111
- create_branch branch
112
- end
113
-
114
- def start_story(story)
115
- puts "Updating story status in Pivotal Tracker..."
116
- story.start!(:owned_by => @options[:full_name])
117
- end
118
-
119
100
  end
data/lib/pivotal/base.rb CHANGED
@@ -30,6 +30,7 @@ module Pivotal
30
30
 
31
31
  def update_attributes(options = {})
32
32
  @xml = resource.put generate_xml(options)
33
+ return self
33
34
  end
34
35
 
35
36
  class << self
@@ -46,11 +47,13 @@ module Pivotal
46
47
 
47
48
  def generate_xml(options = {})
48
49
  builder = Builder::XmlMarkup.new
49
- allowed_keys(options).each do |key, value|
50
- builder.key(value.to_s)
50
+ builder.__send__ self.class.name_as_xml_attribute do
51
+ allowed_keys(options).each do |key, value|
52
+ builder.__send__(key, value.to_s)
53
+ end
51
54
  end
52
55
 
53
- builder
56
+ builder.target!
54
57
  end
55
58
 
56
59
  def allowed_keys(options = {})
data/readme.markdown CHANGED
@@ -13,12 +13,10 @@ This selects the top-most available feature from your Pivotal Tracker, and offer
13
13
  Collecting latest stories from Pivotal Tracker...
14
14
  Story: Test git pivotal
15
15
  URL: http://www.pivotaltracker.com/story/show/1234567
16
- Accept this story? (Yn): y
17
- Suggested branch: feature-1234567
18
- Accept this name? (Yn): y
19
- Creating feature-1234567 branch...
20
- Updating story status in Pivotal Tracker...
21
- 2 git-pick:feature-1234567 %
16
+ Enter branch name (will be prepended by 1234567) [feature]: testing
17
+ Creating branch...
18
+ Creating 1234567-testing branch...
19
+ 2 git-pick:1234567-testing %
22
20
 
23
21
  ##Installation
24
22
  To install git-pivotal, simply run
@@ -43,5 +41,5 @@ This is <del>some seriously</del> alpha software. Several things on the ol' tod
43
41
  * <del>Create a general Pivotal::Base#update_attributes method</del>
44
42
  * <del>`git pick` doesn't update the story to indicate who claimed it</del>
45
43
  * Add command to close/finish currently 'picked' feature
46
- * Reduce verbosity of `git pick`
44
+ * <del>Reduce verbosity of `git pick`</del>
47
45
  * More that I can't recall at the moment
@@ -1,7 +1,66 @@
1
+ require 'spec_helper'
1
2
  require 'commands/pick'
2
3
 
3
4
  describe Pick do
4
- it "should work" do
5
- true
5
+
6
+ before(:each) do
7
+ # stub out git config requests
8
+ Pick.any_instance.expects(:get).times(3).with { |v| v =~ /git config/}.returns("")
6
9
  end
10
+
11
+ it "should set the api key with the -k option" do
12
+ @pick = Pick.new("-k", "1234")
13
+ @pick.options[:api_token].should == "1234"
14
+ end
15
+
16
+ it "should set the api key with the --api-token= option" do
17
+ @pick = Pick.new("--api-key=1234")
18
+ @pick.options[:api_token].should == "1234"
19
+ end
20
+
21
+ it "should set the project id with the -p option" do
22
+ @pick = Pick.new("-p", "1")
23
+ @pick.options[:project_id].should == "1"
24
+ end
25
+
26
+ it "should set the project id with the --project-id= option" do
27
+ @pick = Pick.new("--project-id=1")
28
+ @pick.options[:project_id].should == "1"
29
+ end
30
+
31
+ it "should set the full name with the -n option" do
32
+ @pick = Pick.new("-n", "Jeff Tucker")
33
+ @pick.options[:full_name].should == "Jeff Tucker"
34
+ end
35
+
36
+ it "should set the full name with the --full-name= option" do
37
+ @pick = Pick.new("--full-name=Jeff Tucker")
38
+ @pick.options[:full_name].should == "Jeff Tucker"
39
+ end
40
+
41
+ it "should set the quiet flag with the -q option" do
42
+ @pick = Pick.new("-q")
43
+ @pick.options[:quiet].should be_true
44
+ end
45
+
46
+ it "should set the quiet flag with the --quiet option" do
47
+ @pick = Pick.new("--quiet")
48
+ @pick.options[:quiet].should be_true
49
+ end
50
+
51
+ it "should set the verbose flag with the -v option" do
52
+ @pick = Pick.new("-v")
53
+ @pick.options[:verbose].should be_true
54
+ end
55
+
56
+ it "should set the verbose flag with the --verbose option" do
57
+ @pick = Pick.new("--verbose")
58
+ @pick.options[:verbose].should be_true
59
+ end
60
+
61
+ it "should unset the verbose flag with the --no-verbose option" do
62
+ @pick = Pick.new("--no-verbose")
63
+ @pick.options[:verbose].should be_false
64
+ end
65
+
7
66
  end
@@ -36,7 +36,7 @@ describe Pivotal::Base do
36
36
  describe "updating the remote resource" do
37
37
 
38
38
  before(:each) do
39
- @xml = "<story><current_state>started</current_state></story>"
39
+ @xml = "<api><current_state>started</current_state></api>"
40
40
  @base.resource.expects(:put).with(@xml).returns(@xml)
41
41
  end
42
42
 
@@ -49,7 +49,7 @@ describe Pivotal::Base do
49
49
  end
50
50
 
51
51
  it "should not update attributes which don't exist on the remote model" do
52
- @base.update_attributes(:unknown_attribute => true)
52
+ @base.update_attributes(:current_state => :started, :unknown_attribute => true)
53
53
  end
54
54
 
55
55
  it "should update the stored xml with the new remote model" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-pivotal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Tucker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-29 00:00:00 -05:00
12
+ date: 2010-01-30 00:00:00 -05:00
13
13
  default_executable: git-pick
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,7 @@ extra_rdoc_files:
62
62
  - LICENSE
63
63
  files:
64
64
  - .gitignore
65
+ - CHANGELOG
65
66
  - LICENSE
66
67
  - Rakefile
67
68
  - VERSION