thegarage-gitx 2.7.1 → 2.7.2

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: 09fedfaebdd521708a24d8888081fc9fd069e6ff
4
- data.tar.gz: 4f292966ed0b548879f59eb5462046920585a2cc
3
+ metadata.gz: 5947843d44e97022ee2483913d68e814ce12b4cb
4
+ data.tar.gz: ea8962e5e6aba024574764fd06c97d7f3da4721d
5
5
  SHA512:
6
- metadata.gz: bc46244d36565c05ca6032ab4c8c47de3879d3972991c20b34346d1914534cb3ff4bb46526cadb672d5fa115dcbc85454548b24b8d817c9067464e8e8309cef5
7
- data.tar.gz: 8fce08cfbe03c7dd3eeefc9a10302fe82ab0557df6840942149fa4079cae2ef41329bf30c6de4651bf726222c4ea2c887fa39a8e9d7254631704e7f73f6b067e
6
+ metadata.gz: 35b2bb78ba36e778d3826f642b466a218803420e44b531fac54ded8df46d3fe10a6286dafee64d6b57927c851d4ea44da89129ca39890133f10efd25324e10f9
7
+ data.tar.gz: 7a80b185ddb4d4abaab5f5f655f67d2b14860afbcad068a9e5f1a0d233877f80fcc4e9203f193ebd21dcd13a6fb9e3f538159487a068c1338dacd7fe5a954d47
@@ -45,6 +45,11 @@ module Thegarage
45
45
  def assert_not_protected_branch!(branch, action)
46
46
  raise "Cannot #{action} reserved branch" if RESERVED_BRANCHES.include?(branch) || aggregate_branch?(branch)
47
47
  end
48
+
49
+ # helper to invoke other CLI commands
50
+ def execute_command(command_class, method, args = [])
51
+ command_class.new.send(method, *args)
52
+ end
48
53
  end
49
54
  end
50
55
  end
@@ -18,7 +18,7 @@ module Thegarage
18
18
  print_message(branch, integration_branch)
19
19
 
20
20
  begin
21
- UpdateCommand.new.update
21
+ execute_command(UpdateCommand, :update)
22
22
  rescue
23
23
  fail MergeError, "Merge Conflict Occurred. Please Merge Conflict Occurred. Please fix merge conflict and rerun the integrate command"
24
24
  end
@@ -18,7 +18,7 @@ module Thegarage
18
18
 
19
19
  branch = current_branch.name
20
20
  assert_not_protected_branch!(branch, 'release')
21
- UpdateCommand.new.update
21
+ execute_command(UpdateCommand, :update)
22
22
 
23
23
  find_or_create_pull_request(branch)
24
24
 
@@ -27,8 +27,8 @@ module Thegarage
27
27
  run_cmd "git merge --no-ff #{branch}"
28
28
  run_cmd "git push origin HEAD"
29
29
 
30
- IntegrateCommand.new.integrate('staging')
31
- CleanupCommand.new.cleanup
30
+ execute_command(IntegrateCommand, :integrate, 'staging')
31
+ execute_command(CleanupCommand, :cleanup)
32
32
  end
33
33
  end
34
34
  end
@@ -17,7 +17,7 @@ module Thegarage
17
17
  def find_or_create_pull_request(branch)
18
18
  pull_request = find_pull_request(branch)
19
19
  pull_request ||= begin
20
- UpdateCommand.new.update
20
+ execute_command(UpdateCommand, :update)
21
21
  pull_request = create_pull_request(branch)
22
22
  say 'Created pull request: '
23
23
  say pull_request.html_url, :green
@@ -54,7 +54,7 @@ module Thegarage
54
54
  end
55
55
 
56
56
  def pull_request_body(branch)
57
- changelog = run_cmd "git log #{Thegarage::Gitx::BASE_BRANCH}...#{branch} --no-merges --pretty=format:'* %s%n%b'"
57
+ changelog = run_cmd("git log #{Thegarage::Gitx::BASE_BRANCH}...#{branch} --reverse --no-merges --pretty=format:'* %s%n%b'")
58
58
  description = options[:description]
59
59
 
60
60
  description_template = []
@@ -1,5 +1,5 @@
1
1
  module Thegarage
2
2
  module Gitx
3
- VERSION = '2.7.1'
3
+ VERSION = '2.7.2'
4
4
  end
5
5
  end
@@ -24,16 +24,12 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
24
24
  end
25
25
 
26
26
  describe '#integrate' do
27
- let(:fake_update_command) { double('fake update command') }
28
- before do
29
- allow(Thegarage::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command)
30
- end
31
27
  context 'when integration branch is ommitted and remote branch exists' do
32
28
  let(:authorization_token) { '123123' }
33
29
  let(:remote_branch_names) { ['origin/staging'] }
34
30
  before do
35
31
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
36
- expect(fake_update_command).to receive(:update)
32
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
37
33
 
38
34
  expect(cli).to receive(:run_cmd).with("git fetch origin").ordered
39
35
  expect(cli).to receive(:run_cmd).with("git branch -D staging", allow_failure: true).ordered
@@ -63,7 +59,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
63
59
  let(:remote_branch_names) { ['origin/staging'] }
64
60
  before do
65
61
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
66
- expect(fake_update_command).to receive(:update)
62
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
67
63
 
68
64
  expect(cli).to receive(:run_cmd).with("git fetch origin").ordered
69
65
  expect(cli).to receive(:run_cmd).with("git branch -D staging", allow_failure: true).ordered
@@ -94,7 +90,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
94
90
  before do
95
91
  allow(cli).to receive(:ask_editor).and_return('description')
96
92
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
97
- expect(fake_update_command).to receive(:update).twice
93
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update).twice
98
94
 
99
95
  expect(cli).to receive(:run_cmd).with("git fetch origin").ordered
100
96
  expect(cli).to receive(:run_cmd).with("git branch -D staging", allow_failure: true).ordered
@@ -103,7 +99,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
103
99
  expect(cli).to receive(:run_cmd).with("git push origin HEAD").ordered
104
100
  expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
105
101
 
106
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --no-merges --pretty=format:'* %s%n%b'").and_return("2013-01-01 did some stuff").ordered
102
+ expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %s%n%b'").and_return("2013-01-01 did some stuff").ordered
107
103
 
108
104
  stub_request(:post, 'https://api.github.com/repos/thegarage/thegarage-gitx/pulls').to_return(:status => 201, :body => new_pull_request.to_json, :headers => {'Content-Type' => 'application/json'})
109
105
  stub_request(:post, 'https://api.github.com/repos/thegarage/thegarage-gitx/issues/10/comments').to_return(:status => 201)
@@ -128,7 +124,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
128
124
  let(:remote_branch_names) { [] }
129
125
  before do
130
126
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
131
- expect(fake_update_command).to receive(:update)
127
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
132
128
 
133
129
  expect(repo).to receive(:create_branch).with('staging', 'master')
134
130
 
@@ -159,7 +155,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
159
155
  let(:remote_branch_names) { ['origin/prototype'] }
160
156
  before do
161
157
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
162
- expect(fake_update_command).to receive(:update)
158
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
163
159
 
164
160
  expect(cli).to receive(:run_cmd).with("git fetch origin").ordered
165
161
  expect(cli).to receive(:run_cmd).with("git branch -D prototype", allow_failure: true).ordered
@@ -186,10 +182,10 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
186
182
  expect { cli.integrate('some-other-branch') }.to raise_error(/Invalid aggregate branch: some-other-branch must be one of supported aggregate branches/)
187
183
  end
188
184
  end
189
- context 'when merge conflicts occur during the updatecommand execution' do
185
+ context 'when merge conflicts occur during the Thegarage::Gitx::Cli::updatecommand execution' do
190
186
  let(:remote_branch_names) { ['origin/staging'] }
191
187
  before do
192
- expect(fake_update_command).to receive(:update).and_raise(Thegarage::Gitx::Cli::BaseCommand::MergeError)
188
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update).and_raise(Thegarage::Gitx::Cli::BaseCommand::MergeError)
193
189
 
194
190
  expect { cli.integrate }.to raise_error(Thegarage::Gitx::Cli::BaseCommand::MergeError, 'Merge Conflict Occurred. Please Merge Conflict Occurred. Please fix merge conflict and rerun the integrate command')
195
191
  end
@@ -200,7 +196,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
200
196
  context 'when merge conflicts occur with the integrate command' do
201
197
  let(:remote_branch_names) { ['origin/staging'] }
202
198
  before do
203
- expect(fake_update_command).to receive(:update)
199
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
204
200
 
205
201
  expect(cli).to receive(:run_cmd).with("git fetch origin").ordered
206
202
  expect(cli).to receive(:run_cmd).with("git branch -D staging", allow_failure: true).ordered
@@ -224,7 +220,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
224
220
  before do
225
221
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
226
222
 
227
- expect(fake_update_command).to receive(:update)
223
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
228
224
 
229
225
  expect(cli).not_to receive(:run_cmd).with("git branch -D staging")
230
226
  expect(cli).not_to receive(:run_cmd).with("git push origin HEAD")
@@ -253,7 +249,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
253
249
  let(:authorization_token) { '123123' }
254
250
  before do
255
251
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
256
- expect(fake_update_command).to receive(:update)
252
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
257
253
  expect(cli).to receive(:ask).and_return('feature-branch')
258
254
 
259
255
  expect(cli).not_to receive(:run_cmd).with("git branch -D staging")
@@ -29,16 +29,11 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
29
29
  end
30
30
  end
31
31
  context 'when user confirms release and pull request exists' do
32
- let(:fake_update_command) { double('fake update command', update: nil) }
33
- let(:fake_integrate_command) { double('fake integrate command') }
34
- let(:fake_cleanup_command) { double('fake cleanup command', cleanup: nil) }
35
32
  let(:authorization_token) { '123123' }
36
33
  before do
37
- expect(Thegarage::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command)
38
- expect(Thegarage::Gitx::Cli::IntegrateCommand).to receive(:new).and_return(fake_integrate_command)
39
- expect(Thegarage::Gitx::Cli::CleanupCommand).to receive(:new).and_return(fake_cleanup_command)
40
-
41
- expect(fake_integrate_command).to receive(:integrate).with('staging')
34
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
35
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::IntegrateCommand, :integrate, 'staging')
36
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::CleanupCommand, :cleanup)
42
37
 
43
38
  expect(cli).to receive(:yes?).and_return(true)
44
39
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
@@ -58,9 +53,6 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
58
53
  end
59
54
  context 'when user confirms release and pull request does not exist' do
60
55
  let(:authorization_token) { '123123' }
61
- let(:fake_update_command) { double('fake update command', update: nil) }
62
- let(:fake_integrate_command) { double('fake integrate command') }
63
- let(:fake_cleanup_command) { double('fake cleanup command', cleanup: nil) }
64
56
  let(:new_pull_request) do
65
57
  {
66
58
  html_url: "https://path/to/html/pull/request",
@@ -75,16 +67,13 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
75
67
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
76
68
  allow(cli).to receive(:ask_editor).and_return('description')
77
69
 
78
- expect(Thegarage::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command).twice
79
- expect(Thegarage::Gitx::Cli::IntegrateCommand).to receive(:new).and_return(fake_integrate_command)
80
- expect(Thegarage::Gitx::Cli::CleanupCommand).to receive(:new).and_return(fake_cleanup_command)
81
-
82
- expect(fake_update_command).to receive(:update).twice
83
- expect(fake_integrate_command).to receive(:integrate).with('staging')
70
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update).twice
71
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::IntegrateCommand, :integrate, 'staging')
72
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::CleanupCommand, :cleanup)
84
73
 
85
74
  expect(cli).to receive(:yes?).and_return(true)
86
75
 
87
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --no-merges --pretty=format:'* %s%n%b'").and_return("2013-01-01 did some stuff").ordered
76
+ expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %s%n%b'").and_return("2013-01-01 did some stuff").ordered
88
77
  expect(cli).to receive(:run_cmd).with("git checkout master").ordered
89
78
  expect(cli).to receive(:run_cmd).with("git pull origin master").ordered
90
79
  expect(cli).to receive(:run_cmd).with("git merge --no-ff feature-branch").ordered
@@ -43,7 +43,8 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
43
43
  expect(Thegarage::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command)
44
44
 
45
45
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
46
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --no-merges --pretty=format:'* %s%n%b'").and_return("2013-01-01 did some stuff").ordered
46
+ expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %s%n%b'").and_return("* old commit\n\n* new commit").ordered
47
+ expect(cli).to receive(:ask_editor).with("### Changelog\n* old commit\n\n* new commit\n#{Thegarage::Gitx::Cli::Github::PULL_REQUEST_FOOTER}", anything).and_return('description')
47
48
 
48
49
  stub_request(:post, 'https://api.github.com/repos/thegarage/thegarage-gitx/pulls').to_return(:status => 201, :body => new_pull_request.to_json, :headers => {'Content-Type' => 'application/json'})
49
50
  VCR.use_cassette('pull_request_does_not_exist') do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thegarage-gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek