git_reflow 0.2.5 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -37
- data/README.rdoc +282 -39
- data/Rakefile +0 -11
- data/git_reflow.gemspec +4 -3
- data/lib/git_reflow/version.rb +1 -1
- data/lib/git_reflow.rb +37 -36
- metadata +141 -225
- data/features/step_definitions/debug_steps.rb +0 -4
- data/features/step_definitions/gem_steps.rb +0 -3
- data/features/step_definitions/git_steps.rb +0 -138
- data/features/support/env.rb +0 -27
- data/features/support/gem.rb +0 -85
- data/features/support/github_helpers.rb +0 -3
- data/features/user_delivers_flow.feature +0 -22
- data/features/user_installs_gem.feature +0 -18
- data/features/user_starts_flow.feature +0 -19
- data/spec/fixtures/git/git_config +0 -7
- data/spec/fixtures/pull_requests/pull_request.json +0 -123
- data/spec/fixtures/pull_requests/pull_request_exists_error.json +0 -32
- data/spec/fixtures/pull_requests/pull_requests.json +0 -117
- data/spec/git_reflow_spec.rb +0 -139
- data/spec/spec_helper.rb +0 -28
- data/spec/support/fixtures.rb +0 -8
- data/spec/support/github_helpers.rb +0 -45
- data/spec/support/web_mocks.rb +0 -39
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git_reflow (0.
|
4
|
+
git_reflow (0.3.1)
|
5
5
|
colorize (= 0.5.8)
|
6
6
|
github_api (= 0.7.0)
|
7
7
|
gli (= 2.1.0)
|
@@ -11,28 +11,9 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: http://rubygems.org/
|
13
13
|
specs:
|
14
|
-
addressable (2.3.2)
|
15
|
-
aruba (0.4.11)
|
16
|
-
childprocess (>= 0.2.3)
|
17
|
-
cucumber (>= 1.1.1)
|
18
|
-
ffi (>= 1.0.11)
|
19
|
-
rspec (>= 2.7.0)
|
20
|
-
builder (3.1.3)
|
21
|
-
childprocess (0.3.5)
|
22
|
-
ffi (~> 1.0, >= 1.0.6)
|
23
14
|
colorize (0.5.8)
|
24
|
-
crack (0.3.1)
|
25
|
-
cucumber (1.2.1)
|
26
|
-
builder (>= 2.1.2)
|
27
|
-
diff-lcs (>= 1.1.3)
|
28
|
-
gherkin (~> 2.11.0)
|
29
|
-
json (>= 1.4.6)
|
30
|
-
diff-lcs (1.1.3)
|
31
15
|
faraday (0.8.6)
|
32
16
|
multipart-post (~> 1.1)
|
33
|
-
ffi (1.1.5)
|
34
|
-
gherkin (2.11.2)
|
35
|
-
json (>= 1.4.6)
|
36
17
|
git (1.2.5)
|
37
18
|
github_api (0.7.0)
|
38
19
|
faraday (~> 0.8.1)
|
@@ -42,7 +23,7 @@ GEM
|
|
42
23
|
oauth2
|
43
24
|
gli (2.1.0)
|
44
25
|
hashie (1.2.0)
|
45
|
-
highline (1.6.
|
26
|
+
highline (1.6.16)
|
46
27
|
httpauth (0.2.0)
|
47
28
|
httpclient (2.3.3)
|
48
29
|
jeweler (1.8.4)
|
@@ -53,10 +34,10 @@ GEM
|
|
53
34
|
json (1.7.5)
|
54
35
|
jwt (0.1.5)
|
55
36
|
multi_json (>= 1.0)
|
56
|
-
multi_json (1.
|
37
|
+
multi_json (1.7.2)
|
57
38
|
multi_xml (0.5.3)
|
58
39
|
multipart-post (1.2.0)
|
59
|
-
nokogiri (1.5.
|
40
|
+
nokogiri (1.5.9)
|
60
41
|
oauth2 (0.9.1)
|
61
42
|
faraday (~> 0.8)
|
62
43
|
httpauth (~> 0.1)
|
@@ -68,26 +49,12 @@ GEM
|
|
68
49
|
rake (0.9.2.2)
|
69
50
|
rdoc (3.12)
|
70
51
|
json (~> 1.4)
|
71
|
-
rspec (2.11.0)
|
72
|
-
rspec-core (~> 2.11.0)
|
73
|
-
rspec-expectations (~> 2.11.0)
|
74
|
-
rspec-mocks (~> 2.11.0)
|
75
|
-
rspec-core (2.11.1)
|
76
|
-
rspec-expectations (2.11.3)
|
77
|
-
diff-lcs (~> 1.1.3)
|
78
|
-
rspec-mocks (2.11.2)
|
79
|
-
webmock (1.8.10)
|
80
|
-
addressable (>= 2.2.7)
|
81
|
-
crack (>= 0.1.7)
|
82
52
|
|
83
53
|
PLATFORMS
|
84
54
|
ruby
|
85
55
|
|
86
56
|
DEPENDENCIES
|
87
|
-
aruba (~> 0.4.6)
|
88
57
|
git_reflow!
|
89
58
|
jeweler
|
90
59
|
rake
|
91
60
|
rdoc
|
92
|
-
rspec
|
93
|
-
webmock
|
data/README.rdoc
CHANGED
@@ -1,39 +1,282 @@
|
|
1
|
-
git-reflow
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
1
|
+
= git-reflow
|
2
|
+
|
3
|
+
http://www.reenhanced.com/images/reflow.jpg
|
4
|
+
|
5
|
+
Reflow is a no bullshit git workflow designed to help you maintain quality and get things done.
|
6
|
+
|
7
|
+
== Benefits:
|
8
|
+
* Save minutes every day that add up to hours of more productive time.
|
9
|
+
* Enforce code reviews across your team.
|
10
|
+
* Stop worrying about how to deliver your code and just get work done.
|
11
|
+
* Know that your entire team delivers code the same way.
|
12
|
+
* Reduce the knowledge needed to deliver great code.
|
13
|
+
* Have a commit history that's clean and actually usable.
|
14
|
+
* Revert features with ease (if needed).
|
15
|
+
* Work with diverse teams with less worry about the code delivery process.
|
16
|
+
* Work with diverse teams with less worry about different processes.
|
17
|
+
* Stop searching for other git workflows.
|
18
|
+
Reflow covers 90% of your needs without junk you'll never use.
|
19
|
+
|
20
|
+
== Features:
|
21
|
+
* Automatically create pull requests to master
|
22
|
+
* Automatically ensure that your code is reviewed before merging
|
23
|
+
* Start with sensible commit messages by default
|
24
|
+
* Squash merge feature branches because results are more important than details
|
25
|
+
* Automatically clean up obsolete feature branches after a successful merge
|
26
|
+
|
27
|
+
== Quickstart
|
28
|
+
Create and switch to new branch +nh-branchy-branch+:
|
29
|
+
$ git reflow start nh-branchy-branch
|
30
|
+
|
31
|
+
Create a pull request for your branch against +master+:
|
32
|
+
$ git reflow review
|
33
|
+
|
34
|
+
If your code is 'LGTM'd, squash merge to +master+ and delete the feature branch:
|
35
|
+
$ git reflow deliver
|
36
|
+
|
37
|
+
== How to use
|
38
|
+
|
39
|
+
=== Installation
|
40
|
+
$ gem install reflow
|
41
|
+
or
|
42
|
+
$ gem install git_reflow
|
43
|
+
|
44
|
+
=== Setup
|
45
|
+
git reflow setup
|
46
|
+
|
47
|
+
On your first install, you'll need to setup your Github credentials. These are used only to get an oauth token that's stored in your global git config.
|
48
|
+
We use the Github credentials so we can create pull requests from the command line.
|
49
|
+
|
50
|
+
After installation, run:
|
51
|
+
git reflow setup
|
52
|
+
|
53
|
+
It looks like this:
|
54
|
+
$ git reflow setup
|
55
|
+
Please enter your GitHub username: nhance
|
56
|
+
Please enter your GitHub password (we do NOT store this):
|
57
|
+
|
58
|
+
Your GitHub account was successfully setup!
|
59
|
+
|
60
|
+
This is safe to run multiple times. We don't care.
|
61
|
+
|
62
|
+
=== Starting a feature branch
|
63
|
+
git reflow start
|
64
|
+
|
65
|
+
This sets up a feature branch remotely and brings a local copy to your machine. Yeah, you can do this by hand pretty easily, so skip this command if you want. This is just a handy shortcut with no magic.
|
66
|
+
|
67
|
+
$ git reflow start nh-branch-name
|
68
|
+
|
69
|
+
[PROTIP] Use your initials at the beginning of each branch so your team knows
|
70
|
+
who is responsible for each. My initials are 'NH', so all of my branches start with +nh-+
|
71
|
+
|
72
|
+
=== Reviewing your work
|
73
|
+
git reflow review
|
74
|
+
|
75
|
+
All of our work is reviewed by our team. This helps spread knowledge to multiple parties and keeps the quality of our code consistent.
|
76
|
+
|
77
|
+
The +review+ step creates a pull request for the currently checked out feature branch against master. That's all you want to do most of the time.
|
78
|
+
We assume you know what you're doing, so if you need something different, do it by hand.
|
79
|
+
|
80
|
+
After making commits to your branch, run +review+. Didn't push it up? We don't care, we'll do it for you.
|
81
|
+
|
82
|
+
$ git reflow review
|
83
|
+
|
84
|
+
From github.com:reenhanced/gitreflow
|
85
|
+
* branch master -> FETCH_HEAD
|
86
|
+
Counting objects: 5, done.
|
87
|
+
Delta compression using up to 16 threads.
|
88
|
+
Compressing objects: 100% (3/3), done.
|
89
|
+
Writing objects: 100% (3/3), 1.68 KiB, done.
|
90
|
+
Total 3 (delta 1), reused 0 (delta 0)
|
91
|
+
To git@github.com:reenhanced/gitreflow.git
|
92
|
+
c2ec1b1..1103006 nh-readme-update -> nh-readme-update
|
93
|
+
|
94
|
+
Successfully created pull request #35: Bootstrapping the readme. This is so I can show how review works
|
95
|
+
Pull Request URL: https://github.com/reenhanced/gitreflow/pull/35
|
96
|
+
Would you like to open it in your browser? y
|
97
|
+
|
98
|
+
[OSX/Ubuntu only] You can automatically open your default web browser to the pull request.
|
99
|
+
This lets you edit the pull request with all of the detailed information you'll need before submitting it to your team.
|
100
|
+
|
101
|
+
We output the pull request URL so you can distribute it to your team without leaving the terminal. But don't be a jerk, update the title and description before you send your work around.
|
102
|
+
|
103
|
+
==== How it works
|
104
|
+
Behind the scenes, this is how +review+ works:
|
105
|
+
git fetch origin
|
106
|
+
|
107
|
+
Are we up-to-date with changes from master?
|
108
|
+
If not, fail with "master has newer changes".
|
109
|
+
|
110
|
+
Then,
|
111
|
+
git push origin current-branch # Updates remote branch
|
112
|
+
|
113
|
+
Do we have pull request?
|
114
|
+
If not, create it and print "Pull request created at http://pull-url/". If so, print the url for the existing request.
|
115
|
+
|
116
|
+
=== Checking your branch status
|
117
|
+
git reflow status
|
118
|
+
|
119
|
+
Sometimes you start working on a branch and can't get back to it for a while. It happens. Use +status+ to check on the status of your work.
|
120
|
+
|
121
|
+
$ git reflow status
|
122
|
+
|
123
|
+
Here's the status of your review:
|
124
|
+
branches: reenhanced:nh-readme-update -> reenhanced:master
|
125
|
+
number: 35
|
126
|
+
reviewed by:
|
127
|
+
url: https://github.com/reenhanced/gitreflow/pull/35
|
128
|
+
|
129
|
+
[notice] No one has reviewed your pull request...
|
130
|
+
Would you like to open it in your browser? n
|
131
|
+
|
132
|
+
This gives you details on who's reviewed your pull request. If someone has participated, but not given you a 'LGTM', this will tell you.
|
133
|
+
+status+ prevents you from having to open a browser to find out where your pull request is at. But in case you want to take a look, we give you the option to open it for you.
|
134
|
+
|
135
|
+
=== Delivering approved code
|
136
|
+
git reflow deliver
|
137
|
+
|
138
|
+
You kick butt. You've got your code reviewed and now you're ready to merge it down to +master+ and deploy. Reflow +deliver+ will take care of all of the steps for you to make this happen.
|
139
|
+
|
140
|
+
Reflow's +deliver+ requires you to have a pull request, so you'll be protected on those mornings when the coffee isn't working yet.
|
141
|
+
We built this <b>to get in your way and make you follow the process</b>. If you don't like it, do it by hand. You already know what you're doing.
|
142
|
+
|
143
|
+
You'll be presented with a prefilled commit message based on the body of your pull request which includes the text <code>Closes #XX</code> that will automatically close the associated pull request on github when deliver completes.
|
144
|
+
|
145
|
+
Make a mistake and deliver too early? It happens. You'll be prompted after you edit your commit message if you want to push your updated +master+ to github. If you answer 'n', then you'll want to do <code>git reset --hard origin/master</code> and checkout your branch again.
|
146
|
+
|
147
|
+
This is what it looks like:
|
148
|
+
$ git reflow deliver
|
149
|
+
From github.com:reenhanced/gitreflow
|
150
|
+
* branch master -> FETCH_HEAD
|
151
|
+
Merging pull request #36: 'Enforce at least one LGTM before delivery', from 'reenhanced:nh-fail-without-lgtm' into 'reenhanced:master'
|
152
|
+
Switched to branch 'master'
|
153
|
+
From github.com:reenhanced/gitreflow
|
154
|
+
* branch master -> FETCH_HEAD
|
155
|
+
Already up-to-date.
|
156
|
+
Switched to branch 'nh-fail-without-lgtm'
|
157
|
+
Switched to branch 'master'
|
158
|
+
Updating c2ec1b1..f90e111
|
159
|
+
Fast-forward
|
160
|
+
Squash commit -- not updating HEAD
|
161
|
+
lib/git_reflow.rb | 71 +++++++++++++++++++++++++++----------------------------
|
162
|
+
1 file changed, 35 insertions(+), 36 deletions(-)
|
163
|
+
[master d1b4dd5] Enforces LGTM before deliver, even with no comments.
|
164
|
+
1 file changed, 35 insertions(+), 36 deletions(-)
|
165
|
+
Merge complete!
|
166
|
+
Would you like to push this branch to your remote repo and cleanup your feature branch? y
|
167
|
+
Counting objects: 7, done.
|
168
|
+
Delta compression using up to 16 threads.
|
169
|
+
Compressing objects: 100% (4/4), done.
|
170
|
+
Writing objects: 100% (4/4), 1.38 KiB, done.
|
171
|
+
Total 4 (delta 2), reused 0 (delta 0)
|
172
|
+
To git@github.com:reenhanced/gitreflow.git
|
173
|
+
c2ec1b1..d1b4dd5 master -> master
|
174
|
+
|
175
|
+
To git@github.com:reenhanced/gitreflow.git
|
176
|
+
- [deleted] nh-fail-without-lgtm
|
177
|
+
|
178
|
+
Deleted branch nh-fail-without-lgtm (was f90e111).
|
179
|
+
Nice job buddy.
|
180
|
+
|
181
|
+
This is what the default commit message looks like:
|
182
|
+
Enforces LGTM before deliver, even with no comments.
|
183
|
+
Removes the need to review the pull request yourself if you make a
|
184
|
+
comment.
|
185
|
+
|
186
|
+
Better error message if setup fails.
|
187
|
+
|
188
|
+
Bug fixes.
|
189
|
+
|
190
|
+
Closes #36
|
191
|
+
|
192
|
+
LGTM given by: @codenamev
|
193
|
+
|
194
|
+
Squashed commit of the following:
|
195
|
+
|
196
|
+
commit f90e111
|
197
|
+
Author: Nicholas Hance <nhance@reenhanced.com>
|
198
|
+
Date: Thu Jul 11 15:33:29 2013 -0400
|
199
|
+
...
|
200
|
+
|
201
|
+
==== How it works
|
202
|
+
This is what we do behind the scenes when you do +deliver+
|
203
|
+
|
204
|
+
* Does a pull request exist?
|
205
|
+
|
206
|
+
If not, stop here. You need to run +review+.
|
207
|
+
|
208
|
+
* Has the review been completed? Did we get a +LGTM+ from everyone who's participated?
|
209
|
+
|
210
|
+
If not, show a list of authors that need to provide a +LGTM+.
|
211
|
+
|
212
|
+
If the review is done, it's time to merge. Here's what happens:
|
213
|
+
|
214
|
+
First, update our local +master+ so we don't get conflicts
|
215
|
+
git checkout master
|
216
|
+
git pull origin master
|
217
|
+
|
218
|
+
Next, squash merge our feature branch
|
219
|
+
git merge --squash nh-branch-name
|
220
|
+
|
221
|
+
Now, we'll apply a little magic so we have a great commit message by default. Your editor will open and you'll see a nice default for your commit message based on the pull request body.
|
222
|
+
|
223
|
+
Once you've saved the commit, prompt the user to see if we should continue
|
224
|
+
Merge complete!
|
225
|
+
Would you like to push this branch to your remote repo and cleanup your feature branch?
|
226
|
+
|
227
|
+
If 'y', then we'll push to +master+ and delete the feature branch
|
228
|
+
git push origin master
|
229
|
+
git push origin :nh-branch-name
|
230
|
+
git branch -D nh-branch-name
|
231
|
+
|
232
|
+
If 'n', then just stop here. The user can reset his local +master+.
|
233
|
+
|
234
|
+
And we're done.
|
235
|
+
|
236
|
+
|
237
|
+
== Guiding principles:
|
238
|
+
* You should already know what you're doing.
|
239
|
+
We assume you know how to use git.
|
240
|
+
|
241
|
+
* The +master+ branch is your codebase.
|
242
|
+
You don't need multiple branches for code actually want to use.
|
243
|
+
|
244
|
+
* +master+ should remain stable at all times.
|
245
|
+
The entire team depends on it.
|
246
|
+
|
247
|
+
* No direct commits to +master+.
|
248
|
+
All work happens in feature branches. From a single commit to hundreds.
|
249
|
+
|
250
|
+
* All feature branches are reviewed via pull requests.
|
251
|
+
|
252
|
+
* Looks Good To Me. All feature branches require approval.
|
253
|
+
We look for the string 'LGTM' in a comment on the pull request to know it's ready to merge.
|
254
|
+
|
255
|
+
* If you make a new commit in your branch, you require another review.
|
256
|
+
|
257
|
+
* All participants in a pull request must approve the pull request.
|
258
|
+
If 2 guys comment, you need 2 'LGTM's before the code is ready to merge.
|
259
|
+
|
260
|
+
* Once approved, your feature branch is squash merged to master.
|
261
|
+
This makes the history of the master branch extremely clean and easy to follow.
|
262
|
+
|
263
|
+
* Git blame becomes your friend. You'll know who to blame and can see the full context of changes.
|
264
|
+
Squash commits to master mean every commit represents the whole feature, not a "typo fix".
|
265
|
+
|
266
|
+
|
267
|
+
---
|
268
|
+
|
269
|
+
== Contributing
|
270
|
+
Pull requests are welcome. Please fork and submit. We use this tool every single day and as long as what you want to add doesn't change our workflow, we are happy to accept your updates. Feel free to add your github username to the list below.
|
271
|
+
|
272
|
+
Authors:
|
273
|
+
* @codenamev
|
274
|
+
* @armyofgnomes
|
275
|
+
* @nhance
|
276
|
+
|
277
|
+
Built by Reenhanced:
|
278
|
+
http://www.reenhanced.com
|
279
|
+
|
280
|
+
<B>Looking for a capable team for your project? Get in touch. We're looking to grow.</B>
|
281
|
+
|
282
|
+
<em>Licensed using the MIT license. Do whatever you like with this, but don't blame us if it breaks anything. You're a professional, and you're responsible for the tools you use.</em>
|
data/Rakefile
CHANGED
@@ -1,13 +1,2 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'bundler/gem_tasks'
|
3
|
-
require 'cucumber'
|
4
|
-
require 'cucumber/rake/task'
|
5
|
-
|
6
|
-
Dir[File.join(File.dirname(__FILE__),'lib/tasks/*.rake')].each { |f| load f }
|
7
|
-
|
8
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
9
|
-
t.cucumber_opts = "features --format pretty -x"
|
10
|
-
t.fork = false
|
11
|
-
end
|
12
|
-
|
13
|
-
task :default => [:spec, :cucumber]
|
data/git_reflow.gemspec
CHANGED
@@ -15,18 +15,19 @@ spec = Gem::Specification.new do |s|
|
|
15
15
|
s.has_rdoc = true
|
16
16
|
s.extra_rdoc_files = ['README.rdoc']
|
17
17
|
s.bindir = 'bin'
|
18
|
+
|
18
19
|
s.require_paths << 'lib'
|
19
20
|
s.rdoc_options << '--title' << 'git_reflow' << '--main' << 'README.rdoc' << '-ri'
|
21
|
+
|
20
22
|
s.add_development_dependency('rake')
|
21
23
|
s.add_development_dependency('rdoc')
|
22
|
-
s.add_development_dependency('rspec')
|
23
|
-
s.add_development_dependency('aruba', '~> 0.4.6')
|
24
24
|
s.add_development_dependency('jeweler')
|
25
|
-
|
25
|
+
|
26
26
|
s.add_dependency('colorize', '0.5.8')
|
27
27
|
s.add_dependency('gli', '2.1.0')
|
28
28
|
s.add_dependency('highline')
|
29
29
|
s.add_dependency('httpclient')
|
30
30
|
s.add_dependency('github_api', '0.7.0')
|
31
|
+
|
31
32
|
s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
|
32
33
|
end
|
data/lib/git_reflow/version.rb
CHANGED
data/lib/git_reflow.rb
CHANGED
@@ -13,13 +13,19 @@ module GitReflow
|
|
13
13
|
LGTM = /lgtm|looks good to me|:\+1:|:thumbsup:/i
|
14
14
|
|
15
15
|
def setup
|
16
|
-
gh_user
|
16
|
+
gh_user = ask("Please enter your GitHub username: ")
|
17
17
|
gh_password = ask("Please enter your GitHub password (we do NOT store this): ") { |q| q.echo = false }
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
|
19
|
+
begin
|
20
|
+
github = Github.new :basic_auth => "#{gh_user}:#{gh_password}"
|
21
|
+
authorization = github.oauth.create 'scopes' => ['repo']
|
22
|
+
oauth_token = authorization[:token]
|
23
|
+
set_oauth_token(oauth_token)
|
24
|
+
rescue
|
25
|
+
puts "\nInvalid username or password"
|
26
|
+
else
|
27
|
+
puts "\nYour GitHub account was successfully setup!"
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def status(destination_branch)
|
@@ -67,6 +73,8 @@ module GitReflow
|
|
67
73
|
options['base'] ||= 'master'
|
68
74
|
fetch_destination options['base']
|
69
75
|
|
76
|
+
update_destination(current_branch)
|
77
|
+
|
70
78
|
begin
|
71
79
|
existing_pull_request = find_pull_request( :from => current_branch, :to => options['base'] )
|
72
80
|
|
@@ -75,9 +83,10 @@ module GitReflow
|
|
75
83
|
else
|
76
84
|
|
77
85
|
open_comment_authors = find_authors_of_open_pull_request_comments(existing_pull_request)
|
86
|
+
has_comments = has_pull_request_comments?(existing_pull_request)
|
78
87
|
|
79
88
|
# if there any comment_authors left, then they haven't given a lgtm after the last commit
|
80
|
-
if open_comment_authors.empty? or options['skip-lgtm']
|
89
|
+
if (has_comments and open_comment_authors.empty?) or options['skip-lgtm']
|
81
90
|
lgtm_authors = comment_authors_for_pull_request(existing_pull_request, :with => LGTM)
|
82
91
|
commit_message = existing_pull_request[:body] || get_first_commit_message
|
83
92
|
puts "Merging pull request ##{existing_pull_request.number}: '#{existing_pull_request.title}', from '#{existing_pull_request.head.label}' into '#{existing_pull_request.base.label}'"
|
@@ -102,8 +111,10 @@ module GitReflow
|
|
102
111
|
else
|
103
112
|
puts "There were problems commiting your feature... please check the errors above and try again."
|
104
113
|
end
|
105
|
-
|
114
|
+
elsif open_comment_authors.count > 0
|
106
115
|
puts "[deliver halted] You still need a LGTM from: #{open_comment_authors.join(', ')}"
|
116
|
+
else
|
117
|
+
puts "[deliver halted] Your code has not been reviewed yet."
|
107
118
|
end
|
108
119
|
end
|
109
120
|
|
@@ -188,40 +199,28 @@ module GitReflow
|
|
188
199
|
break
|
189
200
|
end
|
190
201
|
end
|
202
|
+
|
191
203
|
existing_pull_request
|
192
204
|
end
|
193
205
|
|
194
206
|
def pull_request_comments(pull_request)
|
195
|
-
comments = github.issues.comments.all
|
207
|
+
comments = github.issues.comments.all remote_user, remote_repo_name, pull_request.number
|
196
208
|
review_comments = github.pull_requests.comments.all remote_user, remote_repo_name, pull_request.number
|
197
|
-
|
209
|
+
|
210
|
+
review_comments + comments
|
211
|
+
end
|
212
|
+
|
213
|
+
def has_pull_request_comments?(pull_request)
|
214
|
+
pull_request_comments(pull_request).count > 0
|
198
215
|
end
|
199
216
|
|
200
217
|
def find_authors_of_open_pull_request_comments(pull_request)
|
201
218
|
# first we'll gather all the authors that have commented on the pull request
|
202
|
-
|
203
|
-
comment_authors
|
204
|
-
lgtm_authors
|
205
|
-
|
206
|
-
# now we need to check that all the commented authors have given a lgtm after the last commit
|
207
|
-
all_comments.each do |comment|
|
208
|
-
next unless comment_authors.include?(comment.user.login)
|
209
|
-
pull_last_committed_at = get_commited_time(pull_request.head.sha)
|
210
|
-
comment_created_at = Time.parse(comment.created_at)
|
211
|
-
if comment_created_at > pull_last_committed_at
|
212
|
-
if comment[:body] =~ LGTM
|
213
|
-
lgtm_authors |= [comment.user.login]
|
214
|
-
else
|
215
|
-
comment_authors |= [comment.user.login] unless comment_authors.include?(comment.user.login)
|
216
|
-
end
|
217
|
-
else
|
218
|
-
comment_authors -= [comment.user.login] if comment_authors.include?(comment.user.login)
|
219
|
-
end
|
220
|
-
end
|
219
|
+
pull_last_committed_at = get_commited_time(pull_request.head.sha)
|
220
|
+
comment_authors = comment_authors_for_pull_request(pull_request)
|
221
|
+
lgtm_authors = comment_authors_for_pull_request(pull_request, :with => LGTM, :after => pull_last_committed_at)
|
221
222
|
|
222
|
-
comment_authors
|
223
|
-
|
224
|
-
comment_authors || []
|
223
|
+
comment_authors - lgtm_authors
|
225
224
|
end
|
226
225
|
|
227
226
|
def comment_authors_for_pull_request(pull_request, options = {})
|
@@ -230,7 +229,9 @@ module GitReflow
|
|
230
229
|
|
231
230
|
all_comments.each do |comment|
|
232
231
|
next if options[:after] and Time.parse(comment.created_at) < options[:after]
|
233
|
-
|
232
|
+
if (options[:with].nil? or comment[:body] =~ options[:with])
|
233
|
+
comment_authors |= [comment.user.login]
|
234
|
+
end
|
234
235
|
end
|
235
236
|
|
236
237
|
# remove the current user from the list to check
|
@@ -254,7 +255,7 @@ module GitReflow
|
|
254
255
|
last_committed_at = get_commited_time(pull_request.head.sha)
|
255
256
|
lgtm_authors = comment_authors_for_pull_request(pull_request, :with => LGTM, :after => last_committed_at)
|
256
257
|
|
257
|
-
summary_data.merge!("Last comment" => pull_comments.last.
|
258
|
+
summary_data.merge!("Last comment" => pull_comments.last[:body].inspect)
|
258
259
|
|
259
260
|
if lgtm_authors.any?
|
260
261
|
reviewed_by.map! { |author| lgtm_authors.include?(author.uncolorize) ? author.colorize(:green) : author }
|
@@ -262,7 +263,7 @@ module GitReflow
|
|
262
263
|
|
263
264
|
notices << "[notice] You still need a LGTM from: #{open_comment_authors.join(', ')}\n" if open_comment_authors.any?
|
264
265
|
else
|
265
|
-
notices << "[notice] No one has reviewed your pull request
|
266
|
+
notices << "[notice] No one has reviewed your pull request.\n"
|
266
267
|
end
|
267
268
|
|
268
269
|
summary_data['reviewed by'] = reviewed_by.join(', ')
|
@@ -273,7 +274,7 @@ module GitReflow
|
|
273
274
|
printf string_format, "#{name}:", summary_data[name]
|
274
275
|
end
|
275
276
|
|
276
|
-
puts "\n#{notices}"
|
277
|
+
puts "\n#{notices}" unless notices.empty?
|
277
278
|
end
|
278
279
|
|
279
280
|
def get_commited_time(commit_sha)
|