github-pivotal-flow 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 423519e9574e2048faaaec36c2583c3ec79273eb
4
- data.tar.gz: 03fb90bd37c4fb777432e1e9c6c9732ac90b25cf
3
+ metadata.gz: 2d3dc57a3d6971ab0f6f3cc715b8ed92ec6e09a9
4
+ data.tar.gz: d464f101f21dc6d6cfccc0903c73d0b7d8b2c9d5
5
5
  SHA512:
6
- metadata.gz: 2aa8e365a3df85d33431476ca8c8b93bf022edce02ec2f2655f9e32e547469fc6ac36aa9978928b257c09f925505c7d0ce69f77cc24f033b28f0237f9826fa44
7
- data.tar.gz: e6a57b30856b8cfffad4b65b6f34e51109a6240b666e1c4cd1026b2275e2e7b0f40a0dfc3f7102432ece7a5ca4354b86f6fc0c1ae3a6a905b1b9e75dded30bf3
6
+ metadata.gz: 7aa4127d145bc305ac40e50620057dc801aa0e547830939f5d7ab03470396a3b082d5e04cb034cf647a657329bfab08533549d6ce62455440d985e944c36a20d
7
+ data.tar.gz: 873c99a594c2d6684b744b54ae1f803f05730904be0edd15b8f2ed0f18e1557c550c922d725972469a1ffb6117d0d9fe96fe91b15ce618e6e4935ee2b677efa0
@@ -4,7 +4,9 @@ module GithubPivotalFlow
4
4
 
5
5
  # Finishes a Pivotal Tracker story
6
6
  def run!
7
+ raise_error_if_development_or_master
7
8
  story = @configuration.story
9
+ fail("Could not find story associated with branch") unless story
8
10
  story.can_merge?
9
11
  commit_message = options[:commit_message]
10
12
  if story.release?
@@ -17,6 +19,11 @@ module GithubPivotalFlow
17
19
 
18
20
  private
19
21
 
22
+ def raise_error_if_development_or_master
23
+ fail("Cannot finish development branch") if Git.current_branch == @configuration.development_branch
24
+ fail("Cannot finish master branch") if Git.current_branch == @configuration.master_branch
25
+ end
26
+
20
27
  def parse_argv(*args)
21
28
  OptionParser.new do |opts|
22
29
  opts.banner = "Usage: git finish [options]"
@@ -80,7 +80,7 @@ module GithubPivotalFlow
80
80
  end
81
81
 
82
82
  def create_branch!(commit_message = nil, options = {})
83
- commit_message ||= "Starting [#{story_type} ##{id}]: #{name}"
83
+ commit_message ||= "Starting [#{story_type} ##{id}]: #{escape_quotes(name)}"
84
84
  commit_message << " [ci skip]" unless options[:run_ci]
85
85
  print "Creating branch for story with branch name #{branch_name} from #{root_branch_name}... "
86
86
  Git.checkout(root_branch_name)
@@ -111,7 +111,7 @@ module GithubPivotalFlow
111
111
  end
112
112
 
113
113
  def merge_release!(commit_message = nil, options = {})
114
- commit_message ||= "Release #{name}"
114
+ commit_message ||= "Release #{escape_quotes(name)}"
115
115
  commit_message << "\n\n[#{options[:no_complete] ? '' : 'Completes '}##{id}] "
116
116
  print "Merging #{branch_name} to #{master_branch_name}... "
117
117
  Git.checkout(master_branch_name)
@@ -121,9 +121,8 @@ module GithubPivotalFlow
121
121
  else
122
122
  Git.merge(branch_name, commit_message: commit_message, no_ff: true)
123
123
  end
124
- Git.tag(name)
125
124
  print "Merging #{branch_name} to #{development_branch_name}... "
126
- Git checkout(development_branch_name)
125
+ Git.checkout(development_branch_name)
127
126
  Git.pull_remote(development_branch_name)
128
127
  if trivial_merge?(development_branch_name)
129
128
  Git.merge(branch_name, commit_message: commit_message, ff: true)
@@ -131,6 +130,7 @@ module GithubPivotalFlow
131
130
  Git.merge(branch_name, commit_message: commit_message, no_ff: true)
132
131
  end
133
132
  Git.checkout(master_branch_name)
133
+ Git.tag(name)
134
134
  Git.push(master_branch_name, development_branch_name)
135
135
  Git.push_tags
136
136
  self.delete_branch!
@@ -288,5 +288,9 @@ module GithubPivotalFlow
288
288
  prefix = "#{prefix.strip}/" unless prefix.strip[-1,1] == '/'
289
289
  return prefix.strip
290
290
  end
291
+
292
+ def escape_quotes(string)
293
+ string.gsub('"', '\"')
294
+ end
291
295
  end
292
296
  end
@@ -1,3 +1,3 @@
1
1
  module GithubPivotalFlow
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -8,7 +8,7 @@ module GithubPivotalFlow
8
8
  $stderr = StringIO.new
9
9
 
10
10
  @project = double('project')
11
- @story = double('story')
11
+ @story = double('story', branch_name: 'feature/1234-sample_story')
12
12
  @configuration = double('configuration')
13
13
  @configuration.stub(
14
14
  development_branch: 'development',
@@ -26,7 +26,23 @@ module GithubPivotalFlow
26
26
  allow(Configuration).to receive(:new).and_return(@configuration)
27
27
  allow(Project).to receive(:find).and_return(@project)
28
28
  @finish = Finish.new
29
- expect(@configuration).to receive(:story).and_return(@story)
29
+ allow(Git).to receive(:current_branch).and_return(@story.branch_name)
30
+ allow(@configuration).to receive(:story).and_return(@story)
31
+ end
32
+
33
+ it 'fails if you are on the development branch' do
34
+ allow(Git).to receive(:current_branch).and_return(@configuration.development_branch)
35
+ expect { @finish.run! }.to raise_error("Cannot finish development branch")
36
+ end
37
+
38
+ it 'fails if you are on the master branch' do
39
+ allow(Git).to receive(:current_branch).and_return(@configuration.master_branch)
40
+ expect { @finish.run! }.to raise_error("Cannot finish master branch")
41
+ end
42
+
43
+ it 'fails if we cannot find the story this branch relates to' do
44
+ allow(@configuration).to receive(:story).and_return(nil)
45
+ expect { @finish.run! }.to raise_error("Could not find story associated with branch")
30
46
  end
31
47
 
32
48
  it 'merges the branch back to its root by default' do
@@ -163,6 +163,13 @@ module GithubPivotalFlow
163
163
 
164
164
  @story.create_branch!('Message')
165
165
  end
166
+
167
+ it 'supports stories with quotes in their name' do
168
+ @story.stub(name: 'Fancy story with "quotes"', branch_name: 'feature/123456-my_branch')
169
+ expect(Git).to receive(:commit).with(hash_including(commit_message: 'Starting [feature #123456]: Fancy story with \"quotes\" [ci skip]'))
170
+
171
+ @story.create_branch!
172
+ end
166
173
  end
167
174
  end
168
175
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-pivotal-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Piret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline