thegarage-gitx 2.12.0 → 2.13.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: 9c042898972c5d2092ec9f3a579a75e32c448a95
4
- data.tar.gz: a8b5e3cd62170304f12cfdb4000e2325ad77325d
3
+ metadata.gz: 3970bcceec2fdffef729443705a5533f089e25b5
4
+ data.tar.gz: c42d584f27788dfd2491149895442665ce04fb92
5
5
  SHA512:
6
- metadata.gz: a0aca7c57d79390ecfc96913132303a830fa258f6e3dd5d0a5f26de44b584a5cb840324f14ee160b06127cb37c8068eeaad86c5a6ff315fa3b23945ee35db624
7
- data.tar.gz: cb4eed326c8c2ddeb0554d88a8722c84a06e40aab83856f0ee61051a13c9a061ce0b565f9da71b1b8d82b6d56c22a0b6d13f561c472edb72ca3aaac7f5c3b6d8
6
+ metadata.gz: 09941f7c3d161f8a7e8bb9f1167484713d2d12dc40d8fc4ecfddc93a37f51d93ee20319919650205b34ebe8a96ac83c0e0e042a83f2a3f3da237091357bd04c3
7
+ data.tar.gz: d8960f7276396f466d4c606b1e73355cd2a2db010502f1292e787fccc04b5f06bbe17ff411119bfc68fdbd66e28ef0472fb97ea9134abf9a7128c0e50a1d5fee
data/README.md CHANGED
@@ -26,7 +26,7 @@ update the local feature branch with latest remote changes plus upstream release
26
26
 
27
27
  integrate the current feature branch into an aggregate branch (ex: prototype, staging)
28
28
 
29
- ## git review
29
+ ## git review <feature_branch_name (optional, default: current_branch)>
30
30
 
31
31
  create a pull request on github for peer review of the current branch. This command is re-runnable
32
32
  in order to re-assign pull requests.
@@ -41,13 +41,14 @@ options:
41
41
  NOTE: the `--bump` option will also update the pull request commit status to mark the branch as 'pending peer review'.
42
42
  This setting is cleared when a reviewer approves or rejects the pull request.
43
43
 
44
- ## git release
44
+ ## git release <feature_branch_name (optional, default: current_branch)
45
45
 
46
- release the current feature branch to master. This operation will perform the following:
46
+ release the feature branch to master. This operation will perform the following:
47
47
 
48
- * pull in latest code from remote branch
49
- * merge in latest code from master branch
48
+ * pull latest code from remote feature branch
49
+ * pull latest code from master branch
50
50
  * prompt user to confirm they actually want to perform the release
51
+ * check if pull request commit status is currently successful
51
52
  * merge current branch into master
52
53
  * (optional) cleanup merged branches from remote server
53
54
 
@@ -14,11 +14,12 @@ module Thegarage
14
14
 
15
15
  desc 'release', 'release the current branch to production'
16
16
  method_option :cleanup, :type => :boolean, :desc => 'cleanup merged branches after release'
17
- def release
17
+ def release(branch = nil)
18
18
  return unless yes?("Release #{current_branch.name} to production? (y/n)", :green)
19
19
 
20
- branch = current_branch.name
20
+ branch ||= current_branch.name
21
21
  assert_not_protected_branch!(branch, 'release')
22
+ checkout_branch(branch)
22
23
  execute_command(UpdateCommand, :update)
23
24
 
24
25
  find_or_create_pull_request(branch)
@@ -1,7 +1,6 @@
1
1
  require 'thor'
2
2
  require 'thegarage/gitx'
3
3
  require 'thegarage/gitx/cli/base_command'
4
- require 'thegarage/gitx/cli/update_command'
5
4
  require 'thegarage/gitx/github'
6
5
 
7
6
  module Thegarage
@@ -41,10 +40,10 @@ module Thegarage
41
40
  method_option :approve, :type => :boolean, :desc => 'approve the pull request an post comment on pull request'
42
41
  method_option :reject, :type => :boolean, :desc => 'reject the pull request an post comment on pull request'
43
42
  # @see http://developer.github.com/v3/pulls/
44
- def review
43
+ def review(branch = nil)
45
44
  fail 'Github authorization token not found' unless authorization_token
46
45
 
47
- branch = current_branch.name
46
+ branch ||= current_branch.name
48
47
  pull_request = find_or_create_pull_request(branch)
49
48
  bump_pull_request(pull_request) if options[:bump]
50
49
  approve_pull_request(pull_request) if options[:approve]
@@ -1,6 +1,7 @@
1
1
  require 'octokit'
2
2
  require 'fileutils'
3
3
  require 'yaml'
4
+ require 'thegarage/gitx/cli/update_command'
4
5
 
5
6
  module Thegarage
6
7
  module Gitx
@@ -20,6 +21,7 @@ module Thegarage
20
21
  def find_or_create_pull_request(branch)
21
22
  pull_request = find_pull_request(branch)
22
23
  pull_request ||= begin
24
+ checkout_branch(branch)
23
25
  execute_command(Thegarage::Gitx::Cli::UpdateCommand, :update)
24
26
  pull_request = create_pull_request(branch)
25
27
  say 'Created pull request: '
@@ -1,5 +1,5 @@
1
1
  module Thegarage
2
2
  module Gitx
3
- VERSION = '2.12.0'
3
+ VERSION = '2.13.0'
4
4
  end
5
5
  end
@@ -98,7 +98,7 @@ describe Thegarage::Gitx::Cli::IntegrateCommand do
98
98
  expect(cli).to receive(:run_cmd).with("git merge feature-branch").ordered
99
99
  expect(cli).to receive(:run_cmd).with("git push origin HEAD").ordered
100
100
  expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
101
-
101
+ expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
102
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
103
103
 
104
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'})
@@ -61,6 +61,7 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
61
61
  expect(cli).to receive(:yes?).and_return(true)
62
62
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
63
63
 
64
+ expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
64
65
  expect(cli).to receive(:run_cmd).with("git checkout master").ordered
65
66
  expect(cli).to receive(:run_cmd).with("git pull origin master").ordered
66
67
  expect(cli).to receive(:run_cmd).with("git merge --no-ff feature-branch").ordered
@@ -74,6 +75,29 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
74
75
  should meet_expectations
75
76
  end
76
77
  end
78
+ context 'when target_branch is not nil and user confirms release and pull request exists with success status' do
79
+ before do
80
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::UpdateCommand, :update)
81
+ expect(cli).to receive(:execute_command).with(Thegarage::Gitx::Cli::IntegrateCommand, :integrate, 'staging')
82
+ expect(cli).to_not receive(:execute_command).with(Thegarage::Gitx::Cli::CleanupCommand, :cleanup)
83
+
84
+ expect(cli).to receive(:yes?).and_return(true)
85
+ allow(cli).to receive(:authorization_token).and_return(authorization_token)
86
+
87
+ expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
88
+ expect(cli).to receive(:run_cmd).with("git checkout master").ordered
89
+ expect(cli).to receive(:run_cmd).with("git pull origin master").ordered
90
+ expect(cli).to receive(:run_cmd).with("git merge --no-ff feature-branch").ordered
91
+ expect(cli).to receive(:run_cmd).with("git push origin HEAD").ordered
92
+
93
+ VCR.use_cassette('pull_request_does_exist_with_success_status') do
94
+ cli.release 'feature-branch'
95
+ end
96
+ end
97
+ it 'runs expected commands' do
98
+ should meet_expectations
99
+ end
100
+ end
77
101
  context 'when user confirms release and pull request does not exist' do
78
102
  let(:new_pull_request) do
79
103
  {
@@ -96,6 +120,8 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
96
120
  expect(cli).to receive(:yes?).with('Release feature-branch to production? (y/n)', :green).and_return(true)
97
121
  expect(cli).to receive(:yes?).with('Branch status is currently: pending. Proceed with release? (y/n)', :red).and_return(true)
98
122
 
123
+ expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
124
+ expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
99
125
  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
100
126
  expect(cli).to receive(:run_cmd).with("git checkout master").ordered
101
127
  expect(cli).to receive(:run_cmd).with("git pull origin master").ordered
@@ -128,6 +154,7 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
128
154
  expect(cli).to receive(:yes?).and_return(true)
129
155
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
130
156
 
157
+ expect(cli).to receive(:run_cmd).with("git checkout feature-branch").ordered
131
158
  expect(cli).to receive(:run_cmd).with("git checkout master").ordered
132
159
  expect(cli).to receive(:run_cmd).with("git pull origin master").ordered
133
160
  expect(cli).to receive(:run_cmd).with("git merge --no-ff feature-branch").ordered
@@ -140,9 +167,6 @@ describe Thegarage::Gitx::Cli::ReleaseCommand do
140
167
  it 'runs expected commands' do
141
168
  should meet_expectations
142
169
  end
143
- it 'prunes merged branches (git cleanup)' do
144
- should meet_expectations
145
- end
146
170
  end
147
171
  end
148
172
  end
@@ -43,6 +43,7 @@ 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 checkout feature-branch').ordered
46
47
  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
48
  expect(cli).to receive(:ask_editor).with("### Changelog\n* old commit\n\n* new commit\n#{Thegarage::Gitx::Github::PULL_REQUEST_FOOTER}", anything).and_return('description')
48
49
 
@@ -59,6 +60,41 @@ describe Thegarage::Gitx::Cli::ReviewCommand do
59
60
  should meet_expectations
60
61
  end
61
62
  end
63
+ context 'when target branch is not nil and pull request does not exist' do
64
+ let(:authorization_token) { '123123' }
65
+ let(:changelog) { '* made some fixes' }
66
+ let(:fake_update_command) { double('fake update command', update: nil) }
67
+ let(:new_pull_request) do
68
+ {
69
+ html_url: "https://path/to/html/pull/request",
70
+ issue_url: "https://api/path/to/issue/url",
71
+ number: 10,
72
+ head: {
73
+ ref: "branch_name"
74
+ }
75
+ }
76
+ end
77
+ before do
78
+ expect(Thegarage::Gitx::Cli::UpdateCommand).to receive(:new).and_return(fake_update_command)
79
+
80
+ allow(cli).to receive(:authorization_token).and_return(authorization_token)
81
+ expect(cli).to receive(:run_cmd).with('git checkout feature-branch').ordered
82
+ 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
83
+ expect(cli).to receive(:ask_editor).with("### Changelog\n* old commit\n\n* new commit\n#{Thegarage::Gitx::Github::PULL_REQUEST_FOOTER}", anything).and_return('description')
84
+
85
+ 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'})
86
+
87
+ VCR.use_cassette('pull_request_does_not_exist') do
88
+ cli.review 'feature-branch'
89
+ end
90
+ end
91
+ it 'creates github pull request' do
92
+ should meet_expectations
93
+ end
94
+ it 'runs expected commands' do
95
+ should meet_expectations
96
+ end
97
+ end
62
98
  context 'when authorization_token is missing' do
63
99
  let(:authorization_token) { nil }
64
100
  it do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thegarage-gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.0
4
+ version: 2.13.0
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-01-13 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged