git_reflow 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/git_reflow/commands/start.rb +18 -22
- data/lib/git_reflow/git_server/git_hub/pull_request.rb +15 -2
- data/lib/git_reflow/version.rb +1 -1
- data/lib/git_reflow/workflow.rb +61 -59
- data/spec/fixtures/pull_requests/review.json.erb +35 -0
- data/spec/fixtures/pull_requests/reviews.json.erb +16 -0
- data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +56 -17
- data/spec/lib/git_reflow/logger_spec.rb +0 -8
- data/spec/lib/git_reflow/sandbox_spec.rb +1 -1
- data/spec/support/fake_github.rb +16 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a0f1ca6cc67961a74a107c15f826602527d99bf
|
4
|
+
data.tar.gz: 9a6d7e72bf25fcce1ad86b1ea03e9a3da6b62a6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34047eaec41ed1b185d19b6d4066f5541c8602d528d2459aa7603865c351d33967189dfef20544cd8f4a9160794c808ad8608420ba2e4c03e1439cdcb37fba49
|
7
|
+
data.tar.gz: 6942847d01069738d31494b24e05ec247b831e9f7ce4f81ecfeff2d7954b95e1e6404186e01b3462789ce97d1ecfad05c6be480b232dd88e1b4d723a35641134
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,18 @@
|
|
1
|
-
|
2
|
-
desc 'Start will create a new feature branch and setup remote tracking'
|
3
|
-
long_desc <<LONGTIME
|
4
|
-
Performs the following:\n
|
5
|
-
\t$ git checkout <base_branch>\n
|
6
|
-
\t$ git pull origin <base_branch>\n
|
7
|
-
\t$ git push origin <base_branch>:refs/heads/[new_feature_branch]\n
|
8
|
-
\t$ git checkout --track -b [new_feature_branch] origin/[new_feature_branch]\n
|
9
|
-
LONGTIME
|
10
|
-
arg_name '[new-feature-branch-name] - name of the new feature branch'
|
11
|
-
command :start do |c|
|
12
|
-
c.flag [:b,:base], default_value: 'master'
|
13
|
-
c.action do |global_options, options, args|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
1
|
+
|
2
|
+
desc 'Start will create a new feature branch and setup remote tracking'
|
3
|
+
long_desc <<LONGTIME
|
4
|
+
Performs the following:\n
|
5
|
+
\t$ git checkout <base_branch>\n
|
6
|
+
\t$ git pull origin <base_branch>\n
|
7
|
+
\t$ git push origin <base_branch>:refs/heads/[new_feature_branch]\n
|
8
|
+
\t$ git checkout --track -b [new_feature_branch] origin/[new_feature_branch]\n
|
9
|
+
LONGTIME
|
10
|
+
arg_name '[new-feature-branch-name] - name of the new feature branch'
|
11
|
+
command :start do |c|
|
12
|
+
c.flag [:b,:base], default_value: 'master'
|
13
|
+
c.action do |global_options, options, args|
|
14
|
+
|
15
|
+
GitReflow.start feature_branch: args[0], base: options[:base]
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -47,12 +47,18 @@ module GitReflow
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def reviewers
|
50
|
-
comment_authors
|
50
|
+
(comment_authors + pull_request_reviews.map(&:user).map(&:login)).uniq
|
51
51
|
end
|
52
52
|
|
53
53
|
def approvals
|
54
54
|
pull_last_committed_at = get_committed_time(self.head.sha)
|
55
|
-
|
55
|
+
|
56
|
+
approved_reviewers = pull_request_reviews.select { |r| r.state == 'APPROVED' }.map(&:user).map(&:login)
|
57
|
+
|
58
|
+
(
|
59
|
+
comment_authors(with: self.class.approval_regex, after: pull_last_committed_at) +
|
60
|
+
approved_reviewers
|
61
|
+
).uniq
|
56
62
|
end
|
57
63
|
|
58
64
|
def comments
|
@@ -171,6 +177,13 @@ module GitReflow
|
|
171
177
|
|
172
178
|
private
|
173
179
|
|
180
|
+
def pull_request_reviews
|
181
|
+
@pull_request_reviews ||= GitReflow.git_server.connection.pull_requests.reviews.list(
|
182
|
+
user: base.label.split(':').first,
|
183
|
+
repo: GitReflow.git_server.class.remote_repo_name, number: number
|
184
|
+
)
|
185
|
+
end
|
186
|
+
|
174
187
|
def comment_authors(with: nil, after: nil)
|
175
188
|
comment_authors = []
|
176
189
|
|
data/lib/git_reflow/version.rb
CHANGED
data/lib/git_reflow/workflow.rb
CHANGED
@@ -1,59 +1,61 @@
|
|
1
|
-
require 'git_reflow/sandbox'
|
2
|
-
require 'git_reflow/git_helpers'
|
3
|
-
|
4
|
-
module GitReflow
|
5
|
-
module Workflow
|
6
|
-
def self.included base
|
7
|
-
base.extend ClassMethods
|
8
|
-
end
|
9
|
-
|
10
|
-
# @nodoc
|
11
|
-
def self.current
|
12
|
-
workflow_file = GitReflow::Config.get('reflow.workflow')
|
13
|
-
if workflow_file.length > 0 and File.exists?(workflow_file)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# defaults
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
# @
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
args_with_defaults[name] =
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
|
1
|
+
require 'git_reflow/sandbox'
|
2
|
+
require 'git_reflow/git_helpers'
|
3
|
+
|
4
|
+
module GitReflow
|
5
|
+
module Workflow
|
6
|
+
def self.included base
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
# @nodoc
|
11
|
+
def self.current
|
12
|
+
workflow_file = GitReflow::Config.get('reflow.workflow')
|
13
|
+
if workflow_file.length > 0 and File.exists?(workflow_file)
|
14
|
+
GitReflow.logger.debug "Using workflow: #{workflow_file}"
|
15
|
+
eval(File.read(workflow_file))
|
16
|
+
else
|
17
|
+
GitReflow.logger.debug "Using core workflow..."
|
18
|
+
GitReflow::Workflows::Core
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module ClassMethods
|
23
|
+
include GitReflow::Sandbox
|
24
|
+
include GitReflow::GitHelpers
|
25
|
+
|
26
|
+
# Creates a singleton method on the inlcuded class
|
27
|
+
#
|
28
|
+
# This method will take any number of keyword parameters. If @defaults keyword is provided, and the given
|
29
|
+
# key(s) in the defaults are not provided as keyword parameters, then it will use the value given in the
|
30
|
+
# defaults for that parameter.
|
31
|
+
#
|
32
|
+
# @param name [Symbol] the name of the method to create
|
33
|
+
# @param defaults [Hash] keyword arguments to provide fallbacks for
|
34
|
+
#
|
35
|
+
# @yield [a:, b:, c:, ...] Invokes the block with an arbitrary number of keyword arguments
|
36
|
+
def command(name, **params, &block)
|
37
|
+
defaults = params[:defaults] || {}
|
38
|
+
self.define_singleton_method(name) do |**args|
|
39
|
+
args_with_defaults = {}
|
40
|
+
args.each do |name, value|
|
41
|
+
if "#{value}".length <= 0
|
42
|
+
args_with_defaults[name] = defaults[name]
|
43
|
+
else
|
44
|
+
args_with_defaults[name] = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
defaults.each do |name, value|
|
49
|
+
if "#{args_with_defaults[name]}".length <= 0
|
50
|
+
args_with_defaults[name] = value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
block.call(**args_with_defaults)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
extend GitReflow::Workflow
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"id": <%= id || 1 %>,
|
3
|
+
"user": {
|
4
|
+
"login": "<%= author %>",
|
5
|
+
"id": 1,
|
6
|
+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
|
7
|
+
"gravatar_id": "",
|
8
|
+
"url": "https://api.github.com/users/<%= author %>",
|
9
|
+
"html_url": "https://github.com/octocat",
|
10
|
+
"followers_url": "https://api.github.com/users/<%= author %>/followers",
|
11
|
+
"following_url": "https://api.github.com/users/<%= author %>/following{/other_user}",
|
12
|
+
"gists_url": "https://api.github.com/users/<%= author %>/gists{/gist_id}",
|
13
|
+
"starred_url": "https://api.github.com/users/<%= author %>/starred{/owner}{/repo}",
|
14
|
+
"subscriptions_url": "https://api.github.com/users/<%= author %>/subscriptions",
|
15
|
+
"organizations_url": "https://api.github.com/users/<%= author %>/orgs",
|
16
|
+
"repos_url": "https://api.github.com/users/<%= author %>/repos",
|
17
|
+
"events_url": "https://api.github.com/users/<%= author %>/events{/privacy}",
|
18
|
+
"received_events_url": "https://api.github.com/users/<%= author %>/received_events",
|
19
|
+
"type": "User",
|
20
|
+
"site_admin": false
|
21
|
+
},
|
22
|
+
"body": "<%= body || "Nice." %>",
|
23
|
+
"commit_id": "<%= commit_id || "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091"%>",
|
24
|
+
"state": "<%= state || "PENDING" %>",
|
25
|
+
"html_url": "https://github.com/Hello-World/pull/<%= pull_request_number %>#pullrequestreview-<%= id || 1 %>",
|
26
|
+
"pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/<%= pull_request_number %>",
|
27
|
+
"_links": {
|
28
|
+
"html": {
|
29
|
+
"href": "https://github.com/octocat/Hello-World/pull/<%= pull_request_number %>#pullrequestreview-<%= id || 1 %>"
|
30
|
+
},
|
31
|
+
"pull_request": {
|
32
|
+
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/<%= pull_request_number %>"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
[
|
2
|
+
<% reviews_json = [] %>
|
3
|
+
<% reviews.each_with_index do |review, index| %>
|
4
|
+
<% reviews_json << Fixture.new('pull_requests/review.json.erb',
|
5
|
+
id: index,
|
6
|
+
author: review[:author],
|
7
|
+
pull_request_number: pull_request_number,
|
8
|
+
repo_owner: repo_owner,
|
9
|
+
repo_name: repo_name,
|
10
|
+
body: review[:body] || 'Hammer time',
|
11
|
+
state: review[:state] || 'PENDING',
|
12
|
+
commit_id: review[:commit_id] || 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091'
|
13
|
+
).to_s %>
|
14
|
+
<% end %>
|
15
|
+
<%= reviews_json.join(", ") %>
|
16
|
+
]
|
@@ -16,6 +16,7 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
16
16
|
let(:existing_pull_requests) { Fixture.new('pull_requests/pull_requests.json').to_json_hashie }
|
17
17
|
let(:existing_pull_commits) { Fixture.new('pull_requests/commits.json').to_json_hashie }
|
18
18
|
let(:comment_author) { 'octocat' }
|
19
|
+
let(:review_author) { 'octocatty' }
|
19
20
|
let(:feature_branch_name) { existing_pull_request.head.label[/[^:]+$/] }
|
20
21
|
let(:base_branch_name) { existing_pull_request.base.label[/[^:]+$/] }
|
21
22
|
let(:existing_pull_comments) {
|
@@ -30,6 +31,12 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
30
31
|
repo_name: repo,
|
31
32
|
comments: [{author: comment_author}],
|
32
33
|
pull_request_number: existing_pull_request.number).to_json_hashie }
|
34
|
+
let(:existing_pull_reviews) {
|
35
|
+
Fixture.new('pull_requests/reviews.json.erb',
|
36
|
+
repo_owner: user,
|
37
|
+
repo_name: repo,
|
38
|
+
reviews: [{author: comment_author}],
|
39
|
+
pull_request_number: existing_pull_request.number).to_json_hashie }
|
33
40
|
|
34
41
|
let(:pr) { GitReflow::GitServer::GitHub::PullRequest.new(existing_pull_request) }
|
35
42
|
|
@@ -78,12 +85,14 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
78
85
|
repo_name: repo,
|
79
86
|
pull_request: {
|
80
87
|
number: existing_pull_request.number,
|
81
|
-
comments: [{author: comment_author}]
|
88
|
+
comments: [{author: comment_author}],
|
89
|
+
reviews: []
|
82
90
|
},
|
83
91
|
issue: {
|
84
92
|
number: existing_pull_request.number,
|
85
93
|
comments: [{author: comment_author}]
|
86
|
-
}
|
94
|
+
}
|
95
|
+
)
|
87
96
|
end
|
88
97
|
specify { expect(subject).to eql(existing_pull_comments.to_a + existing_issue_comments.to_a) }
|
89
98
|
end
|
@@ -99,7 +108,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
99
108
|
repo_name: repo,
|
100
109
|
pull_request: {
|
101
110
|
number: existing_pull_request.number,
|
102
|
-
comments: nil
|
111
|
+
comments: nil,
|
112
|
+
reviews: nil
|
103
113
|
},
|
104
114
|
issue: {
|
105
115
|
number: existing_pull_request.number,
|
@@ -122,7 +132,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
122
132
|
pull_request: {
|
123
133
|
number: existing_pull_request.number,
|
124
134
|
owner: existing_pull_request.user.login,
|
125
|
-
comments: [{author: 'tito'}, {author: 'bobby'}, {author: 'ringo'}]
|
135
|
+
comments: [{author: 'tito'}, {author: 'bobby'}, {author: 'ringo'}],
|
136
|
+
reviews: [{author: 'nature-boy'}]
|
126
137
|
},
|
127
138
|
issue: {
|
128
139
|
number: existing_pull_request.number,
|
@@ -130,7 +141,7 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
130
141
|
})
|
131
142
|
end
|
132
143
|
|
133
|
-
specify { expect(subject).to eq(['tito', 'bobby', 'randy']) }
|
144
|
+
specify { expect(subject).to eq(['tito', 'bobby', 'randy', 'nature-boy']) }
|
134
145
|
end
|
135
146
|
|
136
147
|
|
@@ -145,7 +156,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
145
156
|
pull_request: {
|
146
157
|
number: existing_pull_request.number,
|
147
158
|
owner: existing_pull_request.head.user.login,
|
148
|
-
comments: []
|
159
|
+
comments: [],
|
160
|
+
reviews: []
|
149
161
|
})
|
150
162
|
allow(GitReflow::GitServer::GitHub::PullRequest).to receive(:minimum_approvals).and_return("0")
|
151
163
|
end
|
@@ -160,7 +172,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
160
172
|
pull_request: {
|
161
173
|
number: existing_pull_request.number,
|
162
174
|
owner: existing_pull_request.head.user.login,
|
163
|
-
comments: []
|
175
|
+
comments: [],
|
176
|
+
reviews: []
|
164
177
|
})
|
165
178
|
allow(GitReflow::GitServer::GitHub::PullRequest).to receive(:minimum_approvals).and_return(nil)
|
166
179
|
allow(pr).to receive(:has_comments?).and_return(true)
|
@@ -178,7 +191,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
178
191
|
pull_request: {
|
179
192
|
number: existing_pull_request.number,
|
180
193
|
owner: existing_pull_request.head.user.login,
|
181
|
-
comments: []
|
194
|
+
comments: [],
|
195
|
+
reviews: []
|
182
196
|
})
|
183
197
|
allow(GitReflow::GitServer::GitHub::PullRequest).to receive(:minimum_approvals).and_return("")
|
184
198
|
allow(pr).to receive(:has_comments?).and_return(true)
|
@@ -196,7 +210,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
196
210
|
pull_request: {
|
197
211
|
number: existing_pull_request.number,
|
198
212
|
owner: existing_pull_request.head.user.login,
|
199
|
-
comments: []
|
213
|
+
comments: [],
|
214
|
+
reviews: []
|
200
215
|
})
|
201
216
|
allow(GitReflow::GitServer::GitHub::PullRequest).to receive(:minimum_approvals).and_return("")
|
202
217
|
allow(pr).to receive(:has_comments?).and_return(true)
|
@@ -269,7 +284,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
269
284
|
pull_request: {
|
270
285
|
number: existing_pull_request.number,
|
271
286
|
owner: existing_pull_request.head.user.login,
|
272
|
-
comments: []
|
287
|
+
comments: [],
|
288
|
+
reviews: []
|
273
289
|
})
|
274
290
|
end
|
275
291
|
|
@@ -284,7 +300,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
284
300
|
pull_request: {
|
285
301
|
number: existing_pull_request.number,
|
286
302
|
owner: existing_pull_request.head.user.login,
|
287
|
-
comments: [{author: 'tito', body: 'This is some funky stuff'}]
|
303
|
+
comments: [{author: 'tito', body: 'This is some funky stuff'}],
|
304
|
+
reviews: []
|
288
305
|
})
|
289
306
|
end
|
290
307
|
|
@@ -299,7 +316,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
299
316
|
pull_request: {
|
300
317
|
number: existing_pull_request.number,
|
301
318
|
owner: existing_pull_request.head.user.login,
|
302
|
-
comments: [{author: 'tito', body: 'LGTM'}]
|
319
|
+
comments: [{author: 'tito', body: 'LGTM'}],
|
320
|
+
reviews: []
|
303
321
|
})
|
304
322
|
end
|
305
323
|
|
@@ -320,7 +338,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
320
338
|
pull_request: {
|
321
339
|
number: existing_pull_request.number,
|
322
340
|
owner: existing_pull_request.head.user.login,
|
323
|
-
comments: [{author: 'tito', body: 'LGTM', created_at: Chronic.parse('1 minute ago')}]
|
341
|
+
comments: [{author: 'tito', body: 'LGTM', created_at: Chronic.parse('1 minute ago')}],
|
342
|
+
reviews: []
|
324
343
|
})
|
325
344
|
end
|
326
345
|
|
@@ -336,7 +355,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
336
355
|
pull_request: {
|
337
356
|
number: existing_pull_request.number,
|
338
357
|
owner: existing_pull_request.head.user.login,
|
339
|
-
comments: [{author: 'tito', body: 'LGTM'},
|
358
|
+
comments: [{author: 'tito', body: 'LGTM'}],
|
359
|
+
reviews: [{author: 'ringo', state: 'CHANGES_REQUESTED'}]
|
340
360
|
})
|
341
361
|
end
|
342
362
|
|
@@ -351,7 +371,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
351
371
|
pull_request: {
|
352
372
|
number: existing_pull_request.number,
|
353
373
|
owner: existing_pull_request.head.user.login,
|
354
|
-
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: ':+1:'}]
|
374
|
+
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: ':+1:'}],
|
375
|
+
reviews: []
|
355
376
|
})
|
356
377
|
|
357
378
|
allow(GitReflow::GitServer::GitHub::PullRequest).to receive(:approval_regex).and_return(/(?i-mx:lgtm|looks good to me|:\+1:|:thumbsup:|:shipit:)/)
|
@@ -361,6 +382,22 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
361
382
|
specify { expect(subject).to eq(['tito', 'ringo']) }
|
362
383
|
end
|
363
384
|
|
385
|
+
context "2 approvals including reviews" do
|
386
|
+
before do
|
387
|
+
FakeGitHub.new(
|
388
|
+
repo_owner: user,
|
389
|
+
repo_name: repo,
|
390
|
+
pull_request: {
|
391
|
+
number: existing_pull_request.number,
|
392
|
+
owner: existing_pull_request.head.user.login,
|
393
|
+
comments: [{author: 'tito', body: 'lgtm'}],
|
394
|
+
reviews: [{author: 'nature-boy', state: 'APPROVED'}]
|
395
|
+
})
|
396
|
+
end
|
397
|
+
|
398
|
+
specify { expect(subject).to eq(['tito', 'nature-boy']) }
|
399
|
+
end
|
400
|
+
|
364
401
|
context "but a new commit has been introduced" do
|
365
402
|
before do
|
366
403
|
FakeGitHub.new(
|
@@ -376,7 +413,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
376
413
|
pull_request: {
|
377
414
|
number: existing_pull_request.number,
|
378
415
|
owner: existing_pull_request.head.user.login,
|
379
|
-
comments: [{author: 'tito', body: 'lgtm', created_at: Chronic.parse('1 minute ago')}, {author: 'ringo', body: ':+1:', created_at: Chronic.parse('1 minute ago')}]
|
416
|
+
comments: [{author: 'tito', body: 'lgtm', created_at: Chronic.parse('1 minute ago')}, {author: 'ringo', body: ':+1:', created_at: Chronic.parse('1 minute ago')}],
|
417
|
+
reviews: []
|
380
418
|
})
|
381
419
|
end
|
382
420
|
|
@@ -396,7 +434,8 @@ describe GitReflow::GitServer::GitHub::PullRequest do
|
|
396
434
|
pull_request: {
|
397
435
|
number: existing_pull_request.number,
|
398
436
|
owner: existing_pull_request.head.user.login,
|
399
|
-
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: 'Cha cha cha'}]
|
437
|
+
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: 'Cha cha cha'}],
|
438
|
+
reviews: []
|
400
439
|
})
|
401
440
|
end
|
402
441
|
|
@@ -6,13 +6,5 @@ describe GitReflow::Logger do
|
|
6
6
|
logger = described_class.new
|
7
7
|
expect(logger.instance_variable_get("@logdev").dev.path).to eq GitReflow::Logger::DEFAULT_LOG_FILE
|
8
8
|
end
|
9
|
-
|
10
|
-
context "when a log path is configured " do
|
11
|
-
it "initializes a new logger with the given path" do
|
12
|
-
allow(GitReflow::Config).to receive(:get).with("reflow.log_file_path").and_return("kenny-loggins.log")
|
13
|
-
logger = described_class.new
|
14
|
-
expect(logger.instance_variable_get("@logdev").dev.path).to eq "kenny-loggins.log"
|
15
|
-
end
|
16
|
-
end
|
17
9
|
end
|
18
10
|
end
|
@@ -4,7 +4,7 @@ RSpec.describe GitReflow::Sandbox do
|
|
4
4
|
describe ".run" do
|
5
5
|
it "is blocking by default when the command exits with a failure" do
|
6
6
|
allow(GitReflow::Sandbox).to receive(:run).and_call_original
|
7
|
-
expect { GitReflow::Sandbox.run("ls wtf") }.to raise_error SystemExit, "
|
7
|
+
expect { GitReflow::Sandbox.run("ls wtf") }.to raise_error SystemExit, "\"ls wtf\" failed to run."
|
8
8
|
end
|
9
9
|
|
10
10
|
it "when blocking is flagged off, the command exits silently" do
|
data/spec/support/fake_github.rb
CHANGED
@@ -21,7 +21,7 @@ class FakeGitHub
|
|
21
21
|
# comments: [{author: comment_author}]
|
22
22
|
# })
|
23
23
|
#
|
24
|
-
def initialize(repo_owner: nil, repo_name: nil, pull_request: {}, issue: {}, commits: [])
|
24
|
+
def initialize(repo_owner: nil, repo_name: nil, pull_request: {}, issue: {}, commits: [], reviews: [])
|
25
25
|
raise "FakeGitHub#new: repo_owner AND repo_name keywords are required" unless repo_owner and repo_name
|
26
26
|
|
27
27
|
self.repo_owner = repo_owner
|
@@ -30,6 +30,7 @@ class FakeGitHub
|
|
30
30
|
stub_github_request(:pull_request, pull_request) if pull_request
|
31
31
|
stub_github_request(:issue, issue) if issue
|
32
32
|
stub_github_request(:commits, commits) if commits.any?
|
33
|
+
stub_github_request(:reviews, reviews) if reviews.any?
|
33
34
|
|
34
35
|
if pull_request and (issue.none? or !issue[:comments])
|
35
36
|
stub_github_request(:issue, pull_request.merge({comments: []}))
|
@@ -118,6 +119,20 @@ class FakeGitHub
|
|
118
119
|
headers: {content_type: "application/json; charset=utf-8"})
|
119
120
|
end
|
120
121
|
|
122
|
+
# Stubbing pull request reviews
|
123
|
+
if object_data[:reviews]
|
124
|
+
stub_request(:get, %r{/repos/#{self.repo_owner}/#{self.repo_name}/pulls/#{object_data[:number] || 1}/reviews}).
|
125
|
+
with(query: {'access_token' => 'a1b2c3d4e5f6g7h8i9j0'}).
|
126
|
+
to_return(body: Fixture.new('pull_requests/reviews.json.erb',
|
127
|
+
repo_owner: self.repo_owner,
|
128
|
+
repo_name: self.repo_name,
|
129
|
+
reviews: object_data[:reviews],
|
130
|
+
pull_request_number: object_data[:number] || 1,
|
131
|
+
body: object_data[:body] || 'Hammer time').to_s,
|
132
|
+
status: 200,
|
133
|
+
headers: {content_type: "application/json; charset=utf-8"})
|
134
|
+
end
|
135
|
+
|
121
136
|
# Stubbing pull request commits
|
122
137
|
#stub_get(%r{#{GitReflow::GitServer::GitHub.api_endpoint}/repos/#{user}/#{repo}/pulls/#{existing_pull_request.number}/commits}).
|
123
138
|
# with(query: {"access_token" => "a1b2c3d4e5f6g7h8i9j0"}).
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_reflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentino Stoll
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-04-
|
13
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: appraisal
|
@@ -307,6 +307,8 @@ files:
|
|
307
307
|
- spec/fixtures/pull_requests/pull_request.json.erb
|
308
308
|
- spec/fixtures/pull_requests/pull_request_exists_error.json
|
309
309
|
- spec/fixtures/pull_requests/pull_requests.json
|
310
|
+
- spec/fixtures/pull_requests/review.json.erb
|
311
|
+
- spec/fixtures/pull_requests/reviews.json.erb
|
310
312
|
- spec/fixtures/repositories/commit.json
|
311
313
|
- spec/fixtures/repositories/commit.json.erb
|
312
314
|
- spec/fixtures/repositories/commits.json.erb
|
@@ -377,6 +379,8 @@ test_files:
|
|
377
379
|
- spec/fixtures/pull_requests/pull_request.json.erb
|
378
380
|
- spec/fixtures/pull_requests/pull_request_exists_error.json
|
379
381
|
- spec/fixtures/pull_requests/pull_requests.json
|
382
|
+
- spec/fixtures/pull_requests/review.json.erb
|
383
|
+
- spec/fixtures/pull_requests/reviews.json.erb
|
380
384
|
- spec/fixtures/repositories/commit.json
|
381
385
|
- spec/fixtures/repositories/commit.json.erb
|
382
386
|
- spec/fixtures/repositories/commits.json.erb
|