gitx 2.16.0 → 2.17.0.pre

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: a8f7eaff73daa4f118fef0f3e96d7b592780a93f
4
- data.tar.gz: ae5ab0f84785a11bd5151c4d594dcffdcff8ea4b
3
+ metadata.gz: 1c47e50026d785901a8fd24360b213bae36d404c
4
+ data.tar.gz: cb4bf8d747cc834bf2c18f63f75c690d752cb10d
5
5
  SHA512:
6
- metadata.gz: a320ac06ff05b0f300e0b8cfbae18ac8cc09eab9150f690d267c67c8f8ce3f4e6baea507d31d95055a53658bfab938201bec4741a9bd8ee8d07332f6f2536fb5
7
- data.tar.gz: 2bd4a7cd98d152cba9f35cfd02f648f831771918cc346ea06c4ab4bb1b839a21650d2dfff2597761e95ebd594b05e7a837d5a9b1691412bb571e1951baa1e4a5
6
+ metadata.gz: cc56fa8b8f1d187dd16a02a4bc67e11a62d429eb49bbc8a9d4efad2934c7f8cdab195d34efc59a3d66e746529031a62c35b067789ef580ffe9723ef1ce868860
7
+ data.tar.gz: 104685ea15c4046c486a4ca5d8426b5ec5edefa54bceba35f1356574e9fb26ed7508ffff549d866611f85815242c594f3412a2224238f087445fe1cb74142d61
@@ -22,10 +22,10 @@ module Gitx
22
22
  raise MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the integrate command'
23
23
  end
24
24
 
25
- integrate_branch(branch, integration_branch) unless options[:resume]
25
+ pull_request = pull_request_for_branch(branch)
26
+ integrate_branch(branch, integration_branch, pull_request) unless options[:resume]
26
27
  checkout_branch branch
27
-
28
- create_integrate_comment(branch) unless config.reserved_branch?(branch)
28
+ create_integrate_comment(pull_request) if pull_request
29
29
  end
30
30
 
31
31
  private
@@ -38,10 +38,17 @@ module Gitx
38
38
  say integration_branch, :green
39
39
  end
40
40
 
41
- def integrate_branch(branch, integration_branch)
41
+ def pull_request_for_branch(branch)
42
+ return nil if config.reserved_branch?(branch)
43
+ find_or_create_pull_request(branch)
44
+ end
45
+
46
+ def integrate_branch(branch, integration_branch, pull_request)
42
47
  fetch_remote_branch(integration_branch)
48
+ commit_message = "[gitx] Integrating #{branch} into #{integration_branch}"
49
+ commit_message += " (Pull request ##{pull_request.number})" if pull_request
43
50
  begin
44
- run_cmd "git merge #{branch}"
51
+ run_cmd %Q(git merge --no-ff -m "#{commit_message}" #{branch})
45
52
  rescue
46
53
  raise MergeError, "Merge conflict occurred. Please fix merge conflict and rerun command with --resume #{branch} flag"
47
54
  end
@@ -83,8 +90,7 @@ module Gitx
83
90
  run_cmd "git push origin #{target_branch}:#{target_branch}"
84
91
  end
85
92
 
86
- def create_integrate_comment(branch)
87
- pull_request = find_or_create_pull_request(branch)
93
+ def create_integrate_comment(pull_request)
88
94
  comment = '[gitx] integrated into staging :twisted_rightwards_arrows:'
89
95
  github_client.add_comment(github_slug, pull_request.number, comment)
90
96
  end
@@ -2,7 +2,6 @@ require 'thor'
2
2
  require 'gitx'
3
3
  require 'gitx/cli/base_command'
4
4
  require 'gitx/cli/update_command'
5
- require 'gitx/cli/cleanup_command'
6
5
  require 'gitx/github'
7
6
 
8
7
  module Gitx
data/lib/gitx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gitx
2
- VERSION = '2.16.0'
2
+ VERSION = '2.17.0.pre'
3
3
  end
@@ -14,6 +14,7 @@ describe Gitx::Cli::IntegrateCommand do
14
14
  let(:repo) { cli.send(:repo) }
15
15
  let(:remote_branch_names) { ['origin/staging', 'origin/prototype'] }
16
16
  let(:local_branch_names) { ['feature-branch'] }
17
+ let(:authorization_token) { '123123' }
17
18
 
18
19
  before do
19
20
  allow(cli).to receive(:current_branch).and_return(current_branch)
@@ -21,20 +22,19 @@ describe Gitx::Cli::IntegrateCommand do
21
22
  allow(branches).to receive(:each_name).with(:local).and_return(local_branch_names)
22
23
  allow(branches).to receive(:each_name).with(:remote).and_return(remote_branch_names)
23
24
  allow(repo).to receive(:branches).and_return(branches)
25
+ allow(cli).to receive(:authorization_token).and_return(authorization_token)
24
26
  end
25
27
 
26
28
  describe '#integrate' do
27
29
  context 'when integration branch is ommitted and remote branch exists' do
28
- let(:authorization_token) { '123123' }
29
30
  let(:remote_branch_names) { ['origin/staging'] }
30
31
  before do
31
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
32
32
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
33
33
 
34
34
  expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
35
35
  expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
36
36
  expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
37
- expect(cli).to receive(:run_cmd).with('git merge feature-branch').ordered
37
+ expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').ordered
38
38
  expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
39
39
  expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
40
40
 
@@ -55,16 +55,14 @@ describe Gitx::Cli::IntegrateCommand do
55
55
  context 'when current_branch == master' do
56
56
  let(:current_branch) { double('fake branch', name: 'master', head?: true) }
57
57
  let(:local_branch_names) { ['master'] }
58
- let(:authorization_token) { '123123' }
59
58
  let(:remote_branch_names) { ['origin/staging'] }
60
59
  before do
61
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
62
60
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
63
61
 
64
62
  expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
65
63
  expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
66
64
  expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
67
- expect(cli).to receive(:run_cmd).with('git merge master').ordered
65
+ expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating master into staging" master').ordered
68
66
  expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
69
67
  expect(cli).to receive(:run_cmd).with('git checkout master').ordered
70
68
 
@@ -78,7 +76,6 @@ describe Gitx::Cli::IntegrateCommand do
78
76
  end
79
77
  end
80
78
  context 'when a pull request doesnt exist for the feature-branch' do
81
- let(:authorization_token) { '123123' }
82
79
  let(:changelog) { '* made some fixes' }
83
80
  let(:new_pull_request) do
84
81
  {
@@ -92,17 +89,16 @@ describe Gitx::Cli::IntegrateCommand do
92
89
  end
93
90
  before do
94
91
  allow(cli).to receive(:ask_editor).and_return('description')
95
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
96
92
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update).twice
97
93
 
94
+ expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
95
+ expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %B'").and_return('2013-01-01 did some stuff').ordered
98
96
  expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
99
97
  expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
100
98
  expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
101
- expect(cli).to receive(:run_cmd).with('git merge feature-branch').ordered
99
+ expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').ordered
102
100
  expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
103
101
  expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
104
- expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
105
- expect(cli).to receive(:run_cmd).with("git log master...feature-branch --reverse --no-merges --pretty=format:'* %B'").and_return('2013-01-01 did some stuff').ordered
106
102
 
107
103
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls').to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
108
104
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/issues/10/comments').to_return(status: 201)
@@ -123,10 +119,8 @@ describe Gitx::Cli::IntegrateCommand do
123
119
  end
124
120
  end
125
121
  context 'when staging branch does not exist remotely' do
126
- let(:authorization_token) { '123123' }
127
122
  let(:remote_branch_names) { [] }
128
123
  before do
129
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
130
124
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
131
125
 
132
126
  expect(repo).to receive(:create_branch).with('staging', 'master')
@@ -136,7 +130,7 @@ describe Gitx::Cli::IntegrateCommand do
136
130
  expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
137
131
  expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
138
132
  expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
139
- expect(cli).to receive(:run_cmd).with('git merge feature-branch').ordered
133
+ expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').ordered
140
134
  expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
141
135
  expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
142
136
 
@@ -151,16 +145,14 @@ describe Gitx::Cli::IntegrateCommand do
151
145
  end
152
146
  end
153
147
  context 'when integration branch == prototype and remote branch exists' do
154
- let(:authorization_token) { '123123' }
155
148
  let(:remote_branch_names) { ['origin/prototype'] }
156
149
  before do
157
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
158
150
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
159
151
 
160
152
  expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
161
153
  expect(cli).to receive(:run_cmd).with('git branch -D prototype', allow_failure: true).ordered
162
154
  expect(cli).to receive(:run_cmd).with('git checkout prototype').ordered
163
- expect(cli).to receive(:run_cmd).with('git merge feature-branch').ordered
155
+ expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into prototype (Pull request #10)" feature-branch').ordered
164
156
  expect(cli).to receive(:run_cmd).with('git push origin HEAD').ordered
165
157
  expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
166
158
 
@@ -198,9 +190,11 @@ describe Gitx::Cli::IntegrateCommand do
198
190
  expect(cli).to receive(:run_cmd).with('git fetch origin').ordered
199
191
  expect(cli).to receive(:run_cmd).with('git branch -D staging', allow_failure: true).ordered
200
192
  expect(cli).to receive(:run_cmd).with('git checkout staging').ordered
201
- expect(cli).to receive(:run_cmd).with('git merge feature-branch').and_raise('git merge feature-branch failed').ordered
193
+ expect(cli).to receive(:run_cmd).with('git merge --no-ff -m "[gitx] Integrating feature-branch into staging (Pull request #10)" feature-branch').and_raise('git merge feature-branch failed').ordered
202
194
 
203
- expect { cli.integrate }.to raise_error(/Merge conflict occurred. Please fix merge conflict and rerun command with --resume feature-branch flag/)
195
+ VCR.use_cassette('pull_request_does_exist_with_success_status') do
196
+ expect { cli.integrate }.to raise_error(/Merge conflict occurred. Please fix merge conflict and rerun command with --resume feature-branch flag/)
197
+ end
204
198
  end
205
199
  it 'raises a helpful error' do
206
200
  should meet_expectations
@@ -213,10 +207,7 @@ describe Gitx::Cli::IntegrateCommand do
213
207
  }
214
208
  end
215
209
  let(:repo) { cli.send(:repo) }
216
- let(:authorization_token) { '123123' }
217
210
  before do
218
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
219
-
220
211
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
221
212
 
222
213
  expect(cli).not_to receive(:run_cmd).with('git branch -D staging')
@@ -240,9 +231,7 @@ describe Gitx::Cli::IntegrateCommand do
240
231
  }
241
232
  end
242
233
  let(:local_branch_names) { ['feature-branch'] }
243
- let(:authorization_token) { '123123' }
244
234
  before do
245
- allow(cli).to receive(:authorization_token).and_return(authorization_token)
246
235
  expect(cli).to receive(:execute_command).with(Gitx::Cli::UpdateCommand, :update)
247
236
  expect(cli).to receive(:ask).and_return('feature-branch')
248
237
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.17.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -331,9 +331,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
331
331
  version: '0'
332
332
  required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  requirements:
334
- - - ">="
334
+ - - ">"
335
335
  - !ruby/object:Gem::Version
336
- version: '0'
336
+ version: 1.3.1
337
337
  requirements: []
338
338
  rubyforge_project:
339
339
  rubygems_version: 2.4.8