git_pivotal_tracker 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -87,6 +87,9 @@ module GitPivotalTracker
|
|
87
87
|
opts.on("-b", "--integration-branch=", "The branch to merge finished stories back down onto") { |b| options[:integration_branch] = b }
|
88
88
|
opts.on("-n", "--full-name=", "Your Pivotal Tracker full name") { |n| options[:full_name] = n }
|
89
89
|
|
90
|
+
|
91
|
+
opts.on("-I", "--include-rejected", "Include rejected stories as well as unstarted ones") { |i| options[:include_rejected] = i }
|
92
|
+
opts.on("-O", "--only-mine", "Only include stories that are assigned to me") { |o| options[:only_mine] = o }
|
90
93
|
opts.on("-F", "--fast-forward", "Merge topic branch with fast forward") { |f| options[:fast_forward] = f }
|
91
94
|
opts.on("-S", "--use-ssl", "Use SSL for connection to Pivotal Tracker") { |s| options[:use_ssl] = s }
|
92
95
|
opts.on("-R", "--rebase", "Fetch and rebase the integration branch before merging") { |r| options[:rebase] = r }
|
@@ -39,7 +39,9 @@ module GitPivotalTracker
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def fetch_story
|
42
|
-
|
42
|
+
state = options[:include_rejected] ? "unstarted,rejected" : "unstarted"
|
43
|
+
conditions = { :current_state => state, :limit => 1 }
|
44
|
+
conditions[:owned_by] = "\"#{options[:full_name]}\"" if options[:only_mine]
|
43
45
|
conditions[:story_type] = type unless type == 'story'
|
44
46
|
project.stories.all(conditions).first
|
45
47
|
end
|
@@ -32,6 +32,14 @@ describe GitPivotalTracker::Base do
|
|
32
32
|
it "leaves full_name nil" do
|
33
33
|
subject.options[:full_name].should be_nil
|
34
34
|
end
|
35
|
+
|
36
|
+
it "leaves include_rejected nil" do
|
37
|
+
subject.options[:include_rejected].should be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "leaves only_mine nil" do
|
41
|
+
subject.options[:only_mine].should be_nil
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
it "sets the api_token" do
|
@@ -54,6 +62,16 @@ describe GitPivotalTracker::Base do
|
|
54
62
|
GitPivotalTracker::Base.new("-n", "Full Name").options[:full_name].should == 'Full Name'
|
55
63
|
end
|
56
64
|
|
65
|
+
it "sets include_rejected" do
|
66
|
+
GitPivotalTracker::Base.new("--include-rejected").options[:include_rejected].should be
|
67
|
+
GitPivotalTracker::Base.new("-I").options[:include_rejected].should be
|
68
|
+
end
|
69
|
+
|
70
|
+
it "sets only_mine" do
|
71
|
+
GitPivotalTracker::Base.new("--only-mine").options[:only_mine].should be
|
72
|
+
GitPivotalTracker::Base.new("-O").options[:only_mine].should be
|
73
|
+
end
|
74
|
+
|
57
75
|
it "sets fast_forward" do
|
58
76
|
GitPivotalTracker::Base.new("--fast-forward").options[:fast_forward].should be
|
59
77
|
GitPivotalTracker::Base.new("-F").options[:fast_forward].should be
|
@@ -147,13 +165,15 @@ describe GitPivotalTracker::Base do
|
|
147
165
|
end
|
148
166
|
|
149
167
|
context "given no prepare-commit-msg hook" do
|
168
|
+
let(:file_name) { ".git/hooks/prepare-commit-msg" }
|
169
|
+
|
150
170
|
before do
|
151
|
-
File.delete
|
171
|
+
File.delete file_name if File.exists? file_name
|
152
172
|
GitPivotalTracker::Base.new
|
153
173
|
end
|
154
174
|
|
155
175
|
it "installs the hook" do
|
156
|
-
File.executable?(
|
176
|
+
File.executable?(file_name).should be
|
157
177
|
end
|
158
178
|
end
|
159
179
|
end
|
@@ -5,10 +5,9 @@ describe GitPivotalTracker::Story do
|
|
5
5
|
before do
|
6
6
|
stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123').
|
7
7
|
to_return :body => File.read("#{FIXTURES_PATH}/project.xml")
|
8
|
+
@story = GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123")
|
8
9
|
end
|
9
10
|
|
10
|
-
let(:story) { GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123") }
|
11
|
-
|
12
11
|
context "given there are no stories" do
|
13
12
|
before do
|
14
13
|
stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted&limit=1').
|
@@ -16,51 +15,83 @@ describe GitPivotalTracker::Story do
|
|
16
15
|
end
|
17
16
|
|
18
17
|
it "fails" do
|
19
|
-
story.run!.should == 1
|
18
|
+
@story.run!.should == 1
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
22
|
context "given there is a story" do
|
24
23
|
before do
|
25
24
|
start_xml = File.read("#{FIXTURES_PATH}/start_story.xml")
|
26
|
-
stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted&limit=1').
|
27
|
-
to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
|
28
25
|
stub_request(:put, 'http://www.pivotaltracker.com/services/v3/projects/123/stories/1234567890').
|
29
26
|
with(:body => start_xml).to_return(:body => start_xml)
|
30
27
|
|
31
|
-
@current_branch = story.repository.head.name
|
28
|
+
@current_branch = @story.repository.head.name
|
29
|
+
|
30
|
+
@expected_branch = 'feature-1234567890-pause_the_film'
|
31
|
+
@story.repository.git.branch({:D => true}, @expected_branch)
|
32
32
|
end
|
33
33
|
|
34
|
-
context "
|
34
|
+
context "when the include-rejected flag is set" do
|
35
35
|
before do
|
36
|
-
@
|
37
|
-
story.repository.git.branch({:D => true}, @expected_branch)
|
36
|
+
@story = GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123", "--include-rejected")
|
38
37
|
|
39
|
-
|
40
|
-
|
38
|
+
stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted,rejected&limit=1').
|
39
|
+
to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
|
41
40
|
end
|
42
41
|
|
43
|
-
it "
|
44
|
-
story.
|
42
|
+
it "succeeds" do
|
43
|
+
@story.should_receive(:gets).and_return "\n"
|
44
|
+
@story.run!.should == 0
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context "
|
48
|
+
context "when the only-mine flag is set" do
|
49
49
|
before do
|
50
|
-
@
|
51
|
-
|
50
|
+
@story = GitPivotalTracker::Story.new("-t", "8a8a8a8", "-p", "123", "--full-name", "Ben Lindsey", "--only-mine")
|
51
|
+
stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted%20owned_by:%22Ben%20Lindsey%22&limit=1').
|
52
|
+
to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
story.
|
55
|
+
it "succeeds" do
|
56
|
+
@story.should_receive(:gets).and_return "\n"
|
57
|
+
@story.run!.should == 0
|
55
58
|
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when the default options are used" do
|
62
|
+
before do
|
63
|
+
stub_request(:get, 'http://www.pivotaltracker.com/services/v3/projects/123/stories?filter=current_state:unstarted&limit=1').
|
64
|
+
to_return :body => File.read("#{FIXTURES_PATH}/one_story.xml")
|
65
|
+
end
|
66
|
+
|
67
|
+
context "then I accept the default branch suffix" do
|
68
|
+
before do
|
69
|
+
@story.should_receive(:gets).and_return "\n"
|
70
|
+
@story.run!
|
71
|
+
end
|
72
|
+
|
73
|
+
it "creates a new branch" do
|
74
|
+
@story.repository.head.name.should == @expected_branch
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "then I customize the branch suffix" do
|
79
|
+
before do
|
80
|
+
@expected_branch = 'feature-1234567890-new_name'
|
81
|
+
@story.repository.git.branch({:D => true}, @expected_branch)
|
82
|
+
|
83
|
+
@story.should_receive(:gets).and_return "new_name\n"
|
84
|
+
@story.run!
|
85
|
+
end
|
56
86
|
|
57
|
-
|
58
|
-
|
87
|
+
it "creates a new branch" do
|
88
|
+
@story.repository.head.name.should == @expected_branch
|
89
|
+
end
|
59
90
|
end
|
60
91
|
end
|
61
92
|
|
62
93
|
after do
|
63
|
-
story.repository.git.checkout({:raise => true}, @current_branch)
|
94
|
+
@story.repository.git.checkout({:raise => true}, @current_branch)
|
64
95
|
end
|
65
96
|
end
|
66
97
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: git_pivotal_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Lindsey
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-31 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|