socialcast-git-extensions 3.3 → 4.0
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/.gitignore +1 -0
- data/README.md +11 -1
- data/bin/git-assignpr +4 -0
- data/bin/git-createpr +4 -0
- data/lib/socialcast-git-extensions/cli.rb +82 -26
- data/lib/socialcast-git-extensions/github.rb +25 -10
- data/lib/socialcast-git-extensions/version.rb +1 -1
- data/socialcast-git-extensions.gemspec +2 -1
- data/spec/cli_spec.rb +554 -220
- data/spec/github_spec.rb +98 -0
- data/spec/spec_helper.rb +1 -1
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1597af4201f51193d8caa155e504dd2c1a1708df
|
4
|
+
data.tar.gz: 3998e46534810aa2ab2245faaa69bdaf728a9e60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e80849b35dd2a830a8d555565f75084cac88d7abec267e1e98822f412ca5daaea88c6ad8a34b64b86f085f7797533d59d8022a0fcc2626c5fb6a0ae7a73ba302
|
7
|
+
data.tar.gz: 5bbd8a91ebff3c6952a0237e64a31d8712ada4af78a79c5bf520dd8616bb8d87f679bb952dcc7cae660660660b490c6463de2fb9e0a02d31d61999131da2f5d0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,8 @@ Test the token with the [`git findpr`](https://github.com/socialcast/socialcast-
|
|
29
29
|
|
30
30
|
### Options
|
31
31
|
* ```--quiet```: suppress posting message in Socialcast
|
32
|
+
* config/scgitx.yml option `share_via_pr_comments`: Set to `true` to post reviewrequest and integration messages
|
33
|
+
as pull request comments instead of Socialcast posts.
|
32
34
|
|
33
35
|
## git start <new_branch_name (optional)>
|
34
36
|
|
@@ -50,9 +52,17 @@ Find pull requests on github including a given commit
|
|
50
52
|
|
51
53
|
List branches merged into remote origin/`branch` and not also merged into origin/`base_branch`
|
52
54
|
|
55
|
+
## git createpr
|
56
|
+
|
57
|
+
create a pull request on github for the current branch, without assigning it for review.
|
58
|
+
|
53
59
|
## git reviewrequest
|
54
60
|
|
55
|
-
create a pull request on github for peer review of the current branch.
|
61
|
+
create and assign a pull request on github for peer review of the current branch. See `assignpr` for additional options.
|
62
|
+
|
63
|
+
## git assignpr
|
64
|
+
|
65
|
+
assign the pull request on github for the current branch for peer review.
|
56
66
|
|
57
67
|
### Optional:
|
58
68
|
Specify a Review Buddy mapping that will reference the local Github username and @mention a pre-assigned review buddy in the Socialcast Review Request message. Specify the mapping by creating a .scgitx YML file relative to the Repo Root: config/scgitx.yml with the following format:
|
data/bin/git-assignpr
ADDED
data/bin/git-createpr
ADDED
@@ -28,13 +28,24 @@ module Socialcast
|
|
28
28
|
RestClient.log = Logger.new(STDOUT) if options[:trace]
|
29
29
|
end
|
30
30
|
|
31
|
-
desc "
|
31
|
+
desc "createpr", "Create a pull request on github"
|
32
32
|
method_option :description, :type => :string, :aliases => '-d', :desc => 'pull request description'
|
33
|
+
# @see http://developer.github.com/v3/pulls/
|
34
|
+
def createpr
|
35
|
+
update unless @skip_update
|
36
|
+
description = options[:description] || editor_input(PULL_REQUEST_DESCRIPTION)
|
37
|
+
branch = current_branch
|
38
|
+
repo = current_repo
|
39
|
+
url = create_pull_request(branch, repo, description)['html_url']
|
40
|
+
say "Pull request created: #{url}"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "assignpr", "Assign the pull request on github for review"
|
33
44
|
method_option :additional_reviewers, :type => :string, :aliases => '-a', :desc => 'add additional reviewers to mention automatically, and skips the prompt'
|
34
45
|
method_option :skip_additional_reviewers, :type => :string, :aliases => '-s', :desc => 'Skips adding additional reviewers'
|
35
46
|
# @see http://developer.github.com/v3/pulls/
|
36
|
-
def
|
37
|
-
update
|
47
|
+
def assignpr(*additional_reviewers)
|
48
|
+
update unless @skip_update
|
38
49
|
|
39
50
|
primary_mention = if buddy = socialcast_review_buddy(current_user)
|
40
51
|
"assigned to @#{buddy}"
|
@@ -58,16 +69,34 @@ module Socialcast
|
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
61
|
-
assignee = github_review_buddy(current_user)
|
62
|
-
|
63
|
-
description = options[:description] || editor_input(PULL_REQUEST_DESCRIPTION)
|
64
72
|
branch = current_branch
|
65
73
|
repo = current_repo
|
66
|
-
|
67
|
-
|
74
|
+
current_pr = current_pr_for_branch(repo, branch)
|
75
|
+
issue_url = current_pr['issue_url']
|
76
|
+
url = current_pr['html_url']
|
77
|
+
|
78
|
+
assignee = github_review_buddy(current_user)
|
79
|
+
assign_pull_request(assignee, issue_url) if assignee
|
68
80
|
|
69
|
-
|
70
|
-
|
81
|
+
if use_pr_comments?
|
82
|
+
issue_message = ['#reviewrequest', primary_mention, secondary_mention, "\n/cc @#{developer_group} #scgitx"].compact.join(' ')
|
83
|
+
comment_on_issue(issue_url, issue_message)
|
84
|
+
else
|
85
|
+
review_message = ["#reviewrequest for #{branch} in #{current_repo}", "PR #{url} #{primary_mention}", '', current_pr['body'], '', secondary_mention, "/cc @#{developer_group} #scgitx", '', changelog_summary(branch)].compact.join("\n").gsub(/\n{2,}/, "\n\n")
|
86
|
+
post review_message, :message_type => 'review_request'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "reviewrequest", "Create and assign a pull request on github"
|
91
|
+
method_option :description, :type => :string, :aliases => '-d', :desc => 'pull request description'
|
92
|
+
method_option :additional_reviewers, :type => :string, :aliases => '-a', :desc => 'add additional reviewers to mention automatically, and skips the prompt'
|
93
|
+
method_option :skip_additional_reviewers, :type => :string, :aliases => '-s', :desc => 'Skips adding additional reviewers'
|
94
|
+
# @see http://developer.github.com/v3/pulls/
|
95
|
+
def reviewrequest(*additional_reviewers)
|
96
|
+
update
|
97
|
+
@skip_update = true
|
98
|
+
createpr
|
99
|
+
assignpr(*additional_reviewers)
|
71
100
|
end
|
72
101
|
|
73
102
|
desc "findpr", "Find pull requests including a given commit"
|
@@ -104,14 +133,21 @@ module Socialcast
|
|
104
133
|
maintenance_branch_url = "https://github.com/#{repo}/tree/#{maintenance_branch}"
|
105
134
|
description = "Backport ##{pull_request_num} to #{maintenance_branch_url}\n***\n#{pull_request_data['body']}"
|
106
135
|
|
107
|
-
|
136
|
+
pr_hash = create_pull_request(backport_branch, repo, description)
|
137
|
+
assign_pull_request(assignee, pr_hash['issue_url']) if assignee
|
108
138
|
|
109
|
-
|
110
|
-
if
|
111
|
-
|
139
|
+
reviewer_mention = "@#{socialcast_reviewer}" if socialcast_reviewer
|
140
|
+
if use_pr_comments?
|
141
|
+
issue_message = ['#reviewrequest backport', reviewer_mention, "/cc @#{developer_group} #scgitx"].compact.join(' ')
|
142
|
+
comment_on_issue(pr_hash['issue_url'], issue_message)
|
143
|
+
else
|
144
|
+
review_message = ["#reviewrequest backport ##{pull_request_num} to #{maintenance_branch} in #{current_repo} #scgitx"]
|
145
|
+
if socialcast_reviewer
|
146
|
+
review_message << "/cc #{reviewer_mention} for #backport track"
|
147
|
+
end
|
148
|
+
review_message << "/cc @#{developer_group}"
|
149
|
+
post review_message.join("\n\n"), :url => pr_hash['html_url'], :message_type => 'review_request'
|
112
150
|
end
|
113
|
-
review_message << "/cc @#{developer_group}"
|
114
|
-
post review_message.join("\n\n"), :url => pull_request_url, :message_type => 'review_request'
|
115
151
|
ensure
|
116
152
|
ENV['BASE_BRANCH'] = original_base_branch
|
117
153
|
end
|
@@ -192,12 +228,26 @@ module Socialcast
|
|
192
228
|
integrate_branch(target_branch, prototype_branch) if target_branch == staging_branch
|
193
229
|
run_cmd "git checkout #{branch}"
|
194
230
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
231
|
+
current_pr = begin
|
232
|
+
current_pr_for_branch(current_repo, current_branch)
|
233
|
+
rescue => e
|
234
|
+
say e.message.to_s
|
235
|
+
nil
|
236
|
+
end
|
199
237
|
|
200
|
-
|
238
|
+
say("WARNING: Unable to find current pull request. Use `git createpr` to create one.", :red) unless current_pr
|
239
|
+
|
240
|
+
if use_pr_comments? && current_pr
|
241
|
+
issue_message = "Integrated into #{target_branch}"
|
242
|
+
comment_on_issue(current_pr['issue_url'], issue_message) unless options[:quiet]
|
243
|
+
else
|
244
|
+
message = <<-EOS.strip_heredoc
|
245
|
+
#worklog integrating #{branch} into #{target_branch} in #{current_repo} #scgitx
|
246
|
+
/cc @#{developer_group}
|
247
|
+
EOS
|
248
|
+
|
249
|
+
post message.strip
|
250
|
+
end
|
201
251
|
end
|
202
252
|
|
203
253
|
desc 'promote', '(DEPRECATED) promote the current branch into staging'
|
@@ -264,12 +314,14 @@ module Socialcast
|
|
264
314
|
integrate_branch(base_branch, staging_branch)
|
265
315
|
cleanup
|
266
316
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
317
|
+
unless use_pr_comments?
|
318
|
+
message = <<-EOS.strip_heredoc
|
319
|
+
#worklog releasing #{branch} to #{base_branch} in #{current_repo} #scgitx
|
320
|
+
/cc @#{developer_group}
|
321
|
+
EOS
|
271
322
|
|
272
|
-
|
323
|
+
post message.strip
|
324
|
+
end
|
273
325
|
end
|
274
326
|
|
275
327
|
private
|
@@ -282,6 +334,10 @@ module Socialcast
|
|
282
334
|
!!config['enforce_staging_before_release']
|
283
335
|
end
|
284
336
|
|
337
|
+
def use_pr_comments?
|
338
|
+
config['share_via_pr_comments'] == true
|
339
|
+
end
|
340
|
+
|
285
341
|
# post a message in socialcast
|
286
342
|
# skip sharing message if CLI quiet option is present
|
287
343
|
def post(message, params = {})
|
@@ -31,9 +31,8 @@ module Socialcast
|
|
31
31
|
throw e
|
32
32
|
end
|
33
33
|
|
34
|
-
# returns the url of the created pull request
|
35
34
|
# @see http://developer.github.com/v3/pulls/
|
36
|
-
def create_pull_request(branch, repo, body
|
35
|
+
def create_pull_request(branch, repo, body)
|
37
36
|
payload = {:title => branch, :base => base_branch, :head => branch, :body => body}.to_json
|
38
37
|
say "Creating pull request for "
|
39
38
|
say "#{branch} ", :green
|
@@ -41,11 +40,7 @@ module Socialcast
|
|
41
40
|
say "#{base_branch} ", :green
|
42
41
|
say "in "
|
43
42
|
say repo, :green
|
44
|
-
|
45
|
-
assign_pull_request(branch, assignee, data) if assignee ## Unfortunately this needs to be done in a seperate request.
|
46
|
-
|
47
|
-
url = data['html_url']
|
48
|
-
url
|
43
|
+
github_api_request("POST", "repos/#{repo}/pulls", payload)
|
49
44
|
end
|
50
45
|
|
51
46
|
# find the PRs matching the given commit hash
|
@@ -56,13 +51,33 @@ module Socialcast
|
|
56
51
|
github_api_request "GET", "search/issues?q=#{query}"
|
57
52
|
end
|
58
53
|
|
59
|
-
|
60
|
-
|
61
|
-
|
54
|
+
# find the PRs for a given branch
|
55
|
+
# https://developer.github.com/v3/pulls/#list-pull-requests
|
56
|
+
def pull_requests_for_branch(repo, branch)
|
57
|
+
head_name = "#{repo.split('/').first}:#{branch}"
|
58
|
+
github_api_request "GET", "repos/#{repo}/pulls?head=#{head_name}"
|
59
|
+
end
|
60
|
+
|
61
|
+
# find the current PR for a given branch
|
62
|
+
def current_pr_for_branch(repo, branch)
|
63
|
+
prs = pull_requests_for_branch(repo, branch)
|
64
|
+
raise "Multiple (#{prs.size}) open PRs for #{branch} found in #{repo}, unable to proceed" if prs.size > 1
|
65
|
+
prs.first
|
66
|
+
end
|
67
|
+
|
68
|
+
def assign_pull_request(assignee, issue_url)
|
69
|
+
issue_payload = { :assignee => assignee }.to_json
|
70
|
+
github_api_request "PATCH", issue_url, issue_payload
|
62
71
|
rescue => e
|
63
72
|
say "Failed to assign pull request: #{e.message}", :red
|
64
73
|
end
|
65
74
|
|
75
|
+
# post a comment on an issue
|
76
|
+
# https://developer.github.com/v3/issues/comments/#create-a-comment
|
77
|
+
def comment_on_issue(issue_url, comment_body)
|
78
|
+
github_api_request 'POST', "#{issue_url}/comments", { :body => comment_body }.to_json
|
79
|
+
end
|
80
|
+
|
66
81
|
# @returns [String] socialcast username to assign the review to
|
67
82
|
# @returns [nil] when no buddy system configured or user not found
|
68
83
|
def socialcast_review_buddy(current_user)
|
@@ -16,13 +16,14 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_runtime_dependency 'rugged', '>= 0.23'
|
18
18
|
s.add_runtime_dependency 'socialcast', '~> 1.3.0'
|
19
|
-
s.add_runtime_dependency 'activesupport', '
|
19
|
+
s.add_runtime_dependency 'activesupport', '>= 4.0'
|
20
20
|
s.add_runtime_dependency 'rest-client', '~> 1.7'
|
21
21
|
s.add_runtime_dependency 'thor', '~> 0.19.1'
|
22
22
|
s.add_runtime_dependency 'rake', '~> 10.3'
|
23
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
24
24
|
s.add_development_dependency 'pry', '~> 0.9.12.6'
|
25
25
|
s.add_development_dependency 'webmock', '~> 1.21'
|
26
|
+
s.add_development_dependency 'byebug'
|
26
27
|
|
27
28
|
s.files = `git ls-files`.split("\n")
|
28
29
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/spec/cli_spec.rb
CHANGED
@@ -3,10 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe Socialcast::Gitx::CLI do
|
4
4
|
let(:stubbed_executed_commands) { [] }
|
5
5
|
|
6
|
-
def
|
6
|
+
def expect_message(message_body, params = {})
|
7
7
|
expect(Socialcast::CommandLine::Message).to receive(:create).with(params.merge(:body => message_body)).and_return(double(:permalink_url => 'https://community.socialcast.com/messages/1234'))
|
8
8
|
end
|
9
9
|
|
10
|
+
let(:git_update_commands) do
|
11
|
+
[
|
12
|
+
"git pull origin FOO",
|
13
|
+
"git pull origin master",
|
14
|
+
"git push origin HEAD"
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
10
18
|
before do
|
11
19
|
Socialcast::Gitx::CLI.instance_eval do # to supress warning from stubbing ldap_config
|
12
20
|
@no_tasks = @no_commands = true
|
@@ -25,12 +33,10 @@ describe Socialcast::Gitx::CLI do
|
|
25
33
|
end
|
26
34
|
|
27
35
|
describe '#update' do
|
28
|
-
|
36
|
+
it do
|
29
37
|
expect_any_instance_of(Socialcast::Gitx::CLI).not_to receive(:post)
|
30
38
|
Socialcast::Gitx::CLI.start ['update']
|
31
|
-
|
32
|
-
it 'should not post message to socialcast' do end # see expectations
|
33
|
-
it 'should run expected commands' do
|
39
|
+
|
34
40
|
expect(stubbed_executed_commands).to eq([
|
35
41
|
'git pull origin FOO',
|
36
42
|
'git pull origin master',
|
@@ -40,107 +46,163 @@ describe Socialcast::Gitx::CLI do
|
|
40
46
|
end
|
41
47
|
|
42
48
|
describe '#integrate' do
|
43
|
-
context '
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Socialcast::Gitx::CLI.start ['integrate']
|
49
|
+
context 'with no existing pull request' do
|
50
|
+
let!(:github_api_pulls_list) do
|
51
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls?head=socialcast:FOO")
|
52
|
+
.to_return(:status => 200, :body => "[]", :headers => {})
|
48
53
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
context 'when target branch is omitted' do
|
55
|
+
it 'defaults to prototype' do
|
56
|
+
expect_message "#worklog integrating FOO into prototype in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
57
|
+
|
58
|
+
Socialcast::Gitx::CLI.start ['integrate']
|
59
|
+
|
60
|
+
expect(stubbed_executed_commands).to eq([
|
61
|
+
"git pull origin FOO",
|
62
|
+
"git pull origin master",
|
63
|
+
"git push origin HEAD",
|
64
|
+
"git branch -D prototype",
|
65
|
+
"git fetch origin",
|
66
|
+
"git checkout prototype",
|
67
|
+
"git pull . FOO",
|
68
|
+
"git push origin HEAD",
|
69
|
+
"git checkout FOO",
|
70
|
+
"git checkout FOO"
|
71
|
+
])
|
72
|
+
expect(github_api_pulls_list).to have_been_requested
|
73
|
+
end
|
63
74
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:prototype_branch).and_return('special-prototype')
|
75
|
+
context 'when target branch is omitted with custom prototype branch' do
|
76
|
+
it 'defaults to the custom prototype branch' do
|
77
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:prototype_branch).and_return('special-prototype')
|
68
78
|
|
69
|
-
|
79
|
+
expect_message "#worklog integrating FOO into special-prototype in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
70
80
|
|
71
|
-
|
81
|
+
Socialcast::Gitx::CLI.start ['integrate']
|
82
|
+
|
83
|
+
expect(stubbed_executed_commands).to eq([
|
84
|
+
"git pull origin FOO",
|
85
|
+
"git pull origin master",
|
86
|
+
"git push origin HEAD",
|
87
|
+
"git branch -D special-prototype",
|
88
|
+
"git fetch origin",
|
89
|
+
"git checkout special-prototype",
|
90
|
+
"git pull . FOO",
|
91
|
+
"git push origin HEAD",
|
92
|
+
"git checkout FOO",
|
93
|
+
"git checkout FOO"
|
94
|
+
])
|
95
|
+
end
|
72
96
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
97
|
+
context 'when target branch == prototype' do
|
98
|
+
it do
|
99
|
+
expect_message "#worklog integrating FOO into prototype in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
100
|
+
|
101
|
+
Socialcast::Gitx::CLI.start ['integrate', 'prototype']
|
102
|
+
|
103
|
+
expect(stubbed_executed_commands).to eq([
|
104
|
+
"git pull origin FOO",
|
105
|
+
"git pull origin master",
|
106
|
+
"git push origin HEAD",
|
107
|
+
"git branch -D prototype",
|
108
|
+
"git fetch origin",
|
109
|
+
"git checkout prototype",
|
110
|
+
"git pull . FOO",
|
111
|
+
"git push origin HEAD",
|
112
|
+
"git checkout FOO",
|
113
|
+
"git checkout FOO"
|
114
|
+
])
|
115
|
+
end
|
87
116
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
stub_message "#worklog integrating FOO into prototype in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
117
|
+
context 'when target branch == staging' do
|
118
|
+
it do
|
119
|
+
expect_message "#worklog integrating FOO into staging in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
92
120
|
|
93
|
-
|
121
|
+
Socialcast::Gitx::CLI.start ['integrate', 'staging']
|
122
|
+
|
123
|
+
expect(stubbed_executed_commands).to eq([
|
124
|
+
"git pull origin FOO",
|
125
|
+
"git pull origin master",
|
126
|
+
"git push origin HEAD",
|
127
|
+
"git branch -D staging",
|
128
|
+
"git fetch origin",
|
129
|
+
"git checkout staging",
|
130
|
+
"git pull . FOO",
|
131
|
+
"git push origin HEAD",
|
132
|
+
"git checkout FOO",
|
133
|
+
"git branch -D prototype",
|
134
|
+
"git fetch origin",
|
135
|
+
"git checkout prototype",
|
136
|
+
"git pull . staging",
|
137
|
+
"git push origin HEAD",
|
138
|
+
"git checkout staging",
|
139
|
+
"git checkout FOO"
|
140
|
+
])
|
141
|
+
end
|
94
142
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
"git branch -D prototype",
|
102
|
-
"git fetch origin",
|
103
|
-
"git checkout prototype",
|
104
|
-
"git pull . FOO",
|
105
|
-
"git push origin HEAD",
|
106
|
-
"git checkout FOO",
|
107
|
-
"git checkout FOO"
|
108
|
-
])
|
143
|
+
context 'when target branch != staging || prototype' do
|
144
|
+
it do
|
145
|
+
expect {
|
146
|
+
Socialcast::Gitx::CLI.start ['integrate', 'asdfasdfasdf']
|
147
|
+
}.to raise_error(/Only aggregate branches are allowed for integration/)
|
148
|
+
end
|
109
149
|
end
|
110
150
|
end
|
111
|
-
context '
|
151
|
+
context 'with an existing pull request' do
|
152
|
+
let!(:github_api_pulls_list) do
|
153
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls?head=socialcast:FOO")
|
154
|
+
.to_return(:status => 200, :body => %q([{"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://api.github.com/repos/repo/project/issues/1", "body":"testing"}]))
|
155
|
+
end
|
156
|
+
let!(:github_api_comments_create) do
|
157
|
+
stub_request(:post, "http://api.github.com/repos/repo/project/issues/1/comments")
|
158
|
+
.with(:body => "{\"body\":\"Integrated into prototype\"}")
|
159
|
+
.to_return(:status => 200, :body => "{}", :headers => {})
|
160
|
+
end
|
112
161
|
before do
|
113
|
-
|
114
|
-
|
115
|
-
Socialcast::Gitx::CLI.start ['integrate', 'staging']
|
162
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:use_pr_comments?).and_return(use_pr_comments)
|
116
163
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
"git
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
164
|
+
context 'when use_pr_comments? is false' do
|
165
|
+
let(:use_pr_comments) { false }
|
166
|
+
it 'does not comment on the PR posts a message' do
|
167
|
+
expect_message "#worklog integrating FOO into prototype in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
168
|
+
Socialcast::Gitx::CLI.start ['integrate']
|
169
|
+
|
170
|
+
expect(stubbed_executed_commands).to eq([
|
171
|
+
"git pull origin FOO",
|
172
|
+
"git pull origin master",
|
173
|
+
"git push origin HEAD",
|
174
|
+
"git branch -D prototype",
|
175
|
+
"git fetch origin",
|
176
|
+
"git checkout prototype",
|
177
|
+
"git pull . FOO",
|
178
|
+
"git push origin HEAD",
|
179
|
+
"git checkout FOO",
|
180
|
+
"git checkout FOO"
|
181
|
+
])
|
182
|
+
expect(github_api_pulls_list).to have_been_requested
|
183
|
+
expect(github_api_comments_create).to_not have_been_requested
|
184
|
+
end
|
137
185
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
186
|
+
context 'when use_pr_comments? is true' do
|
187
|
+
let(:use_pr_comments) { true }
|
188
|
+
it 'comments on the PR and does not post a message' do
|
189
|
+
Socialcast::Gitx::CLI.start ['integrate']
|
190
|
+
|
191
|
+
expect(stubbed_executed_commands).to eq([
|
192
|
+
"git pull origin FOO",
|
193
|
+
"git pull origin master",
|
194
|
+
"git push origin HEAD",
|
195
|
+
"git branch -D prototype",
|
196
|
+
"git fetch origin",
|
197
|
+
"git checkout prototype",
|
198
|
+
"git pull . FOO",
|
199
|
+
"git push origin HEAD",
|
200
|
+
"git checkout FOO",
|
201
|
+
"git checkout FOO"
|
202
|
+
])
|
203
|
+
expect(github_api_pulls_list).to have_been_requested
|
204
|
+
expect(github_api_comments_create).to have_been_requested
|
205
|
+
end
|
144
206
|
end
|
145
207
|
end
|
146
208
|
end
|
@@ -163,38 +225,52 @@ describe Socialcast::Gitx::CLI do
|
|
163
225
|
end
|
164
226
|
context 'when user confirms release' do
|
165
227
|
before do
|
166
|
-
stub_message "#worklog releasing FOO to master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
167
|
-
|
168
228
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:yes?).and_return(true)
|
169
229
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:cleanup)
|
170
|
-
Socialcast::Gitx::CLI.start ['release']
|
171
230
|
end
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
231
|
+
shared_examples_for 'releasing the branch' do
|
232
|
+
it do
|
233
|
+
expect(stubbed_executed_commands).to eq([
|
234
|
+
"git branch -D last_known_good_staging",
|
235
|
+
"git fetch origin",
|
236
|
+
"git checkout last_known_good_staging",
|
237
|
+
"git checkout FOO",
|
238
|
+
"git pull origin FOO",
|
239
|
+
"git pull origin master",
|
240
|
+
"git push origin HEAD",
|
241
|
+
"git checkout master",
|
242
|
+
"git pull origin master",
|
243
|
+
"git pull . FOO",
|
244
|
+
"git push origin HEAD",
|
245
|
+
"git branch -D staging",
|
246
|
+
"git fetch origin",
|
247
|
+
"git checkout staging",
|
248
|
+
"git pull . master",
|
249
|
+
"git push origin HEAD",
|
250
|
+
"git checkout master"
|
251
|
+
])
|
252
|
+
end
|
253
|
+
end
|
254
|
+
context 'when use_pr_comments? is false' do
|
255
|
+
before do
|
256
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:use_pr_comments?).and_return(false)
|
257
|
+
expect_message "#worklog releasing FOO to master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
258
|
+
Socialcast::Gitx::CLI.start ['release']
|
259
|
+
end
|
260
|
+
it_behaves_like 'releasing the branch'
|
261
|
+
end
|
262
|
+
context 'when use_pr_comments? is true' do
|
263
|
+
before do
|
264
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:use_pr_comments?).and_return(true)
|
265
|
+
Socialcast::Gitx::CLI.start ['release']
|
266
|
+
end
|
267
|
+
# does not post a message nor a pr comment (github reports "merged" event via webhook)'
|
268
|
+
it_behaves_like 'releasing the branch'
|
193
269
|
end
|
194
270
|
end
|
195
271
|
|
196
272
|
context 'when the branch is not in last_known_good_staging' do
|
197
|
-
context '
|
273
|
+
context 'when enforce_staging_before_release = true' do
|
198
274
|
let(:branches_in_last_known_good_staging) { ['another-branch'] }
|
199
275
|
before do
|
200
276
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:enforce_staging_before_release?).and_return(true)
|
@@ -204,16 +280,16 @@ describe Socialcast::Gitx::CLI do
|
|
204
280
|
expect { Socialcast::Gitx::CLI.start ['release'] }.to raise_error(RuntimeError, 'Cannot release FOO unless it has already been promoted separately to staging and the build has passed.')
|
205
281
|
end
|
206
282
|
end
|
207
|
-
context '
|
283
|
+
context 'when enforce_staging_before_release = false' do
|
208
284
|
let(:branches_in_last_known_good_staging) { ['another-branch'] }
|
209
285
|
before do
|
210
|
-
|
286
|
+
expect_message "#worklog releasing FOO to master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
211
287
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:enforce_staging_before_release?).and_return(false)
|
212
288
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:yes?).and_return(true)
|
213
289
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:cleanup)
|
214
290
|
Socialcast::Gitx::CLI.start ['release']
|
215
291
|
end
|
216
|
-
it
|
292
|
+
it do
|
217
293
|
expect(stubbed_executed_commands).to eq([
|
218
294
|
"git pull origin FOO",
|
219
295
|
"git pull origin master",
|
@@ -235,9 +311,9 @@ describe Socialcast::Gitx::CLI do
|
|
235
311
|
|
236
312
|
context 'with reserved_branches via config file' do
|
237
313
|
before do
|
238
|
-
|
314
|
+
expect_message "#worklog releasing FOO to master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
239
315
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:yes?).and_return(true)
|
240
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return(
|
316
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return('reserved_branches' => ['dont-del-me', 'dont-del-me-2'])
|
241
317
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:cleanup)
|
242
318
|
Socialcast::Gitx::CLI.start ['release']
|
243
319
|
end
|
@@ -248,19 +324,16 @@ describe Socialcast::Gitx::CLI do
|
|
248
324
|
end
|
249
325
|
|
250
326
|
context 'with alternative base branch via config file' do
|
251
|
-
|
252
|
-
|
327
|
+
it do
|
328
|
+
expect_message "#worklog releasing FOO to special-master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
253
329
|
|
254
330
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:yes?).and_return(true)
|
255
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return(
|
331
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return('base_branch' => 'special-master')
|
256
332
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:cleanup)
|
257
333
|
Socialcast::Gitx::CLI.start ['release']
|
258
|
-
|
259
|
-
it 'should post message to socialcast' do end # see expectations
|
260
|
-
it "treats the alternative base branch as reserved" do
|
334
|
+
|
261
335
|
expect(Socialcast::Gitx::CLI.new.send(:reserved_branches)).to include 'special-master'
|
262
|
-
|
263
|
-
it 'should run expected commands' do
|
336
|
+
|
264
337
|
expect(stubbed_executed_commands).to eq([
|
265
338
|
"git branch -D last_known_good_staging",
|
266
339
|
"git fetch origin",
|
@@ -285,7 +358,7 @@ describe Socialcast::Gitx::CLI do
|
|
285
358
|
|
286
359
|
context 'with alternative base branch via environment variable' do
|
287
360
|
before do
|
288
|
-
|
361
|
+
expect_message "#worklog releasing FOO to special-master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
289
362
|
|
290
363
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:yes?).and_return(true)
|
291
364
|
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return({})
|
@@ -296,11 +369,9 @@ describe Socialcast::Gitx::CLI do
|
|
296
369
|
after do
|
297
370
|
ENV.delete('BASE_BRANCH')
|
298
371
|
end
|
299
|
-
it
|
372
|
+
it do
|
300
373
|
expect(Socialcast::Gitx::CLI.new.send(:reserved_branches)).to include 'special-master'
|
301
|
-
|
302
|
-
it 'should post message to socialcast' do end # see expectations
|
303
|
-
it 'should run expected commands' do
|
374
|
+
|
304
375
|
expect(stubbed_executed_commands).to eq([
|
305
376
|
"git branch -D last_known_good_staging",
|
306
377
|
"git fetch origin",
|
@@ -325,10 +396,10 @@ describe Socialcast::Gitx::CLI do
|
|
325
396
|
|
326
397
|
context 'with alternative base branch via environment variable overriding base branch in config' do
|
327
398
|
before do
|
328
|
-
|
399
|
+
expect_message "#worklog releasing FOO to special-master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
329
400
|
|
330
401
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:yes?).and_return(true)
|
331
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return(
|
402
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return('base_branch' => 'extra-special-master')
|
332
403
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:cleanup)
|
333
404
|
ENV['BASE_BRANCH'] = 'special-master'
|
334
405
|
Socialcast::Gitx::CLI.start ['release']
|
@@ -339,9 +410,7 @@ describe Socialcast::Gitx::CLI do
|
|
339
410
|
it "treats the alternative base branch as reserved" do
|
340
411
|
expect(Socialcast::Gitx::CLI.new.send(:reserved_branches)).to include 'special-master'
|
341
412
|
expect(Socialcast::Gitx::CLI.new.send(:reserved_branches)).to include 'extra-special-master'
|
342
|
-
|
343
|
-
it 'should post message to socialcast' do end # see expectations
|
344
|
-
it 'should run expected commands' do
|
413
|
+
|
345
414
|
expect(stubbed_executed_commands).to eq([
|
346
415
|
"git branch -D last_known_good_staging",
|
347
416
|
"git fetch origin",
|
@@ -410,10 +479,10 @@ describe Socialcast::Gitx::CLI do
|
|
410
479
|
before { allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:branches).and_return([]) }
|
411
480
|
context 'when target branch == staging and --destination == last_known_good_staging' do
|
412
481
|
before do
|
413
|
-
|
482
|
+
expect_message "#worklog resetting staging branch to last_known_good_staging in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
414
483
|
Socialcast::Gitx::CLI.start ['nuke', 'staging', '--destination', 'last_known_good_staging']
|
415
484
|
end
|
416
|
-
it
|
485
|
+
it do
|
417
486
|
expect(stubbed_executed_commands).to eq([
|
418
487
|
"git checkout master",
|
419
488
|
"git branch -D last_known_good_staging",
|
@@ -430,12 +499,12 @@ describe Socialcast::Gitx::CLI do
|
|
430
499
|
end
|
431
500
|
context 'when target branch == qa and destination prompt == nil and using custom aggregate_branches config' do
|
432
501
|
before do
|
433
|
-
|
434
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return(
|
502
|
+
expect_message "#worklog resetting qa branch to last_known_good_qa in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
503
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return('aggregate_branches' => ['staging', 'qa'])
|
435
504
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:ask).and_return('')
|
436
505
|
Socialcast::Gitx::CLI.start ['nuke', 'qa']
|
437
506
|
end
|
438
|
-
it 'defaults to last_known_good_qa
|
507
|
+
it 'defaults to last_known_good_qa' do
|
439
508
|
expect(stubbed_executed_commands).to eq([
|
440
509
|
"git checkout master",
|
441
510
|
"git branch -D last_known_good_qa",
|
@@ -452,12 +521,12 @@ describe Socialcast::Gitx::CLI do
|
|
452
521
|
end
|
453
522
|
context 'when target branch == qa and destination prompt = master and using custom aggregate_branches config' do
|
454
523
|
before do
|
455
|
-
|
456
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return(
|
524
|
+
expect_message "#worklog resetting qa branch to last_known_good_master in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
525
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return('aggregate_branches' => ['staging', 'qa'])
|
457
526
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:ask).and_return('master')
|
458
527
|
Socialcast::Gitx::CLI.start ['nuke', 'qa']
|
459
528
|
end
|
460
|
-
it
|
529
|
+
it do
|
461
530
|
expect(stubbed_executed_commands).to eq([
|
462
531
|
"git checkout master",
|
463
532
|
"git branch -D last_known_good_master",
|
@@ -483,17 +552,17 @@ describe Socialcast::Gitx::CLI do
|
|
483
552
|
end
|
484
553
|
end
|
485
554
|
it 'raises an error when target branch is not an aggregate branch' do
|
555
|
+
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:ask).and_return('master')
|
486
556
|
expect {
|
487
|
-
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:ask).and_return('master')
|
488
557
|
Socialcast::Gitx::CLI.start ['nuke', 'asdfasdf']
|
489
558
|
}.to raise_error(/Only aggregate branches are allowed to be reset/)
|
490
559
|
end
|
491
560
|
end
|
492
561
|
|
493
562
|
describe '#backportpr' do
|
494
|
-
|
563
|
+
let(:pr_response) do
|
495
564
|
# https://developer.github.com/v3/search/#search-issues
|
496
|
-
|
565
|
+
{
|
497
566
|
"url" => "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59",
|
498
567
|
"id" => 13712197,
|
499
568
|
"html_url" => "https://github.com/socialcast/socialcast-git-extensions/pull/59",
|
@@ -792,8 +861,9 @@ describe Socialcast::Gitx::CLI do
|
|
792
861
|
"deletions" => 2,
|
793
862
|
"changed_files" => 2
|
794
863
|
}
|
795
|
-
|
796
|
-
|
864
|
+
end
|
865
|
+
let(:commits_response) do
|
866
|
+
[
|
797
867
|
{
|
798
868
|
"sha" => "5e30d5af3f4d1bb3a34cc97568299be028b65f6f",
|
799
869
|
"commit" => {
|
@@ -865,30 +935,87 @@ describe Socialcast::Gitx::CLI do
|
|
865
935
|
]
|
866
936
|
}
|
867
937
|
]
|
938
|
+
end
|
939
|
+
let!(:github_pr_show) do
|
940
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59")
|
941
|
+
.to_return(:status => 200, :body => pr_response.to_json, :headers => {})
|
942
|
+
end
|
943
|
+
let!(:github_pr_commits_list) do
|
944
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls/59/commits")
|
945
|
+
.to_return(:status => 200, :body => commits_response.to_json, :headers => {})
|
946
|
+
end
|
947
|
+
let!(:github_pr_create) do
|
948
|
+
stub_request(:post, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls")
|
949
|
+
.with(:body => "{\"title\":\"backport_59_to_v1.x\",\"base\":\"v1.x\",\"head\":\"backport_59_to_v1.x\",\"body\":\"Backport #59 to https://github.com/socialcast/socialcast-git-extensions/tree/v1.x\\n***\\nsimply testing this out\"}")
|
950
|
+
.to_return(:status => 200, :body => '{"html_url": "https://github.com/socialcast/socialcast-git-extensions/pulls/60", "issue_url": "https://api.github.com/repos/repo/project/issues/60"}', :headers => { 'Content-Type' => 'application/json' })
|
951
|
+
end
|
952
|
+
let!(:github_pr_comment_create) do
|
953
|
+
stub_request(:post, "https://api.github.com/repos/repo/project/issues/60/comments")
|
954
|
+
.with(:body => "{\"body\":\"#reviewrequest backport /cc @SocialcastDevelopers #scgitx\"}")
|
955
|
+
.to_return(:status => 200, :body => "{}", :headers => {})
|
956
|
+
end
|
957
|
+
let!(:socialcast_message_create) do
|
958
|
+
stub_request(:post, "https://testuser:testpassword@testdomain/api/messages.json")
|
959
|
+
.with(:body => "{\"message\":{\"url\":\"https://github.com/socialcast/socialcast-git-extensions/pulls/60\",\"message_type\":\"review_request\",\"body\":\"#reviewrequest backport #59 to v1.x in socialcast/socialcast-git-extensions #scgitx\\n\\n/cc @SocialcastDevelopers\"}}")
|
960
|
+
.to_return(:status => 200, :body => "", :headers => {})
|
961
|
+
end
|
962
|
+
before do
|
963
|
+
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:backportpr).and_call_original
|
964
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:use_pr_comments?).and_return(use_pr_comments)
|
965
|
+
end
|
966
|
+
context 'when use_pr_comments? is false' do
|
967
|
+
let(:use_pr_comments) { false }
|
968
|
+
it 'creates a branch based on v1.x and cherry-picks in PR 59' do
|
969
|
+
Socialcast::Gitx::CLI.start ['backportpr', '59', 'v1.x']
|
970
|
+
expect(github_pr_show).to have_been_requested
|
971
|
+
expect(github_pr_commits_list).to have_been_requested
|
972
|
+
expect(github_pr_create).to have_been_requested
|
868
973
|
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
974
|
+
expect(github_pr_comment_create).to_not have_been_requested
|
975
|
+
expect(socialcast_message_create).to have_been_requested
|
976
|
+
end
|
977
|
+
end
|
978
|
+
context 'when use_pr_comments? is true' do
|
979
|
+
let(:use_pr_comments) { true }
|
980
|
+
it 'posts a pr comment instead of posting a socialcast message' do
|
981
|
+
Socialcast::Gitx::CLI.start ['backportpr', '59', 'v1.x']
|
982
|
+
expect(github_pr_show).to have_been_requested
|
983
|
+
expect(github_pr_commits_list).to have_been_requested
|
984
|
+
expect(github_pr_create).to have_been_requested
|
879
985
|
|
880
|
-
|
986
|
+
expect(github_pr_comment_create).to have_been_requested
|
987
|
+
expect(socialcast_message_create).to_not have_been_requested
|
988
|
+
end
|
989
|
+
end
|
990
|
+
context 'when a backport reviewer is configured' do
|
991
|
+
before do
|
992
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:github_track_reviewer).with('Backport').and_return('janedoe')
|
993
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:socialcast_track_reviewer).with('Backport').and_return('JaneDoe')
|
994
|
+
end
|
995
|
+
let(:use_pr_comments) { true }
|
996
|
+
let!(:github_pr_comment_create) do
|
997
|
+
stub_request(:post, "https://api.github.com/repos/repo/project/issues/60/comments")
|
998
|
+
.with(:body => "{\"body\":\"#reviewrequest backport @JaneDoe /cc @SocialcastDevelopers #scgitx\"}")
|
999
|
+
.to_return(:status => 200, :body => "{}", :headers => {})
|
1000
|
+
end
|
1001
|
+
let!(:github_assign_pr) { stub_request(:patch, "https://api.github.com/repos/repo/project/issues/60").to_return(:status => 200) }
|
1002
|
+
it 'mentions the track reviewer' do
|
1003
|
+
Socialcast::Gitx::CLI.start ['backportpr', '59', 'v1.x']
|
1004
|
+
expect(github_pr_show).to have_been_requested
|
1005
|
+
expect(github_pr_commits_list).to have_been_requested
|
1006
|
+
expect(github_pr_create).to have_been_requested
|
1007
|
+
expect(github_assign_pr).to have_been_requested
|
881
1008
|
|
882
|
-
|
883
|
-
|
1009
|
+
expect(github_pr_comment_create).to have_been_requested
|
1010
|
+
expect(socialcast_message_create).to_not have_been_requested
|
1011
|
+
end
|
884
1012
|
end
|
885
|
-
it 'creates a branch based on v1.x and cherry-picks in PR 59' do end
|
886
1013
|
end
|
887
1014
|
|
888
1015
|
describe '#findpr' do
|
889
|
-
|
1016
|
+
let(:issue_response) do
|
890
1017
|
# https://developer.github.com/v3/search/#search-issues
|
891
|
-
|
1018
|
+
{
|
892
1019
|
"total_count"=> 280,
|
893
1020
|
"items"=> [{
|
894
1021
|
"url" => "https://api.github.com/repos/batterseapower/pinyin-toolkit/issues/132",
|
@@ -938,98 +1065,300 @@ describe Socialcast::Gitx::CLI do
|
|
938
1065
|
"score" => 1.3859273
|
939
1066
|
}]
|
940
1067
|
}
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
to_return(:status => 200, :body =>
|
1068
|
+
end
|
1069
|
+
let!(:github_issue_search) do
|
1070
|
+
stub_request(:get, "https://api.github.com/search/issues?q=abc123%20type:pr%20repo:socialcast/socialcast-git-extensions")
|
1071
|
+
.to_return(:status => 200, :body => issue_response.to_json, :headers => {})
|
1072
|
+
end
|
1073
|
+
it do
|
945
1074
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:findpr).and_call_original
|
946
1075
|
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:say).with("Searching github pull requests for abc123")
|
947
1076
|
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:say).with("\nhttps://github.com/batterseapower/pinyin-toolkit/issues/132\n\tLine Number Indexes Beyond 20 Not Displayed\n\tNick3C 2009-07-12T20:10:41Z")
|
948
1077
|
Socialcast::Gitx::CLI.start ['findpr', 'abc123']
|
1078
|
+
expect(github_issue_search).to have_been_requested
|
949
1079
|
end
|
950
|
-
it 'fetches the data from github and prints it out' do end
|
951
1080
|
end
|
952
1081
|
|
953
1082
|
describe '#reviewrequest' do
|
1083
|
+
let!(:github_create_pr) do
|
1084
|
+
stub_request(:post, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls")
|
1085
|
+
.to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://api.github.com/repos/repo/project/issues/1"}), :headers => {})
|
1086
|
+
end
|
1087
|
+
let!(:github_find_pr_for_branch) do
|
1088
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls?head=socialcast:FOO")
|
1089
|
+
.to_return(:status => 200, :body => %q([{"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://api.github.com/repos/repo/project/issues/1", "body":"testing"}]), :headers => {})
|
1090
|
+
end
|
1091
|
+
let(:stub_github_create_pr_comment) do
|
1092
|
+
stub_request(:post, "http://api.github.com/repos/repo/project/issues/1/comments")
|
1093
|
+
.with(:body => pr_comment_body)
|
1094
|
+
.to_return(:status => 200, :body => "{}", :headers => {})
|
1095
|
+
end
|
1096
|
+
let(:use_pr_comments) { false }
|
1097
|
+
before do
|
1098
|
+
stub_github_create_pr_comment
|
1099
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:use_pr_comments?).and_return(use_pr_comments)
|
1100
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:changelog_summary).and_return('1 file changed')
|
1101
|
+
end
|
954
1102
|
context 'when there are no review_buddies specified' do
|
955
1103
|
before do
|
956
1104
|
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config_file).and_return(Pathname(''))
|
957
1105
|
end
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
stub_message "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 \n\ntesting\n\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed", :message_type => 'review_request'
|
964
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:changelog_summary).and_return('1 file changed')
|
1106
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest \\n/cc @SocialcastDevelopers #scgitx\"}" }
|
1107
|
+
context 'when use_pr_comments? is false' do
|
1108
|
+
it do
|
1109
|
+
expect_message "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 \n\ntesting\n\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed", :message_type => 'review_request'
|
965
1110
|
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1111
|
+
|
1112
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1113
|
+
expect(github_create_pr).to have_been_requested
|
1114
|
+
expect(github_find_pr_for_branch).to have_been_requested
|
1115
|
+
|
1116
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
966
1117
|
end
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1118
|
+
end
|
1119
|
+
context 'when use_pr_comments? is true' do
|
1120
|
+
let(:use_pr_comments) { true }
|
1121
|
+
it do
|
1122
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1123
|
+
|
1124
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1125
|
+
expect(github_create_pr).to have_been_requested
|
1126
|
+
expect(github_find_pr_for_branch).to have_been_requested
|
1127
|
+
|
1128
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
975
1129
|
end
|
976
1130
|
end
|
977
1131
|
end
|
978
1132
|
|
979
1133
|
context 'when review_buddies are specified via a /config YML file' do
|
1134
|
+
let!(:github_assign_pr) { stub_request(:patch, "http://api.github.com/repos/repo/project/issues/1").to_return(:status => 200) }
|
980
1135
|
before do
|
981
|
-
stub_request(:post, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls").
|
982
|
-
to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://github.com/repos/repo/project/issues/1"}), :headers => {})
|
983
|
-
stub_request(:patch, "http://github.com/repos/repo/project/issues/1").to_return(:status => 200)
|
984
1136
|
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:socialcast_review_buddy).and_return('JaneDoe')
|
985
|
-
|
1137
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:github_review_buddy).and_return('janedoe')
|
1138
|
+
end
|
986
1139
|
context 'and additional reviewers are specified' do
|
987
1140
|
let(:message_body) { "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 assigned to @JaneDoe\n\ntesting\n\nAssigned additionally to @JohnSmith for API review\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed" }
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
1141
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest assigned to @JaneDoe \\nAssigned additionally to @JohnSmith for API review \\n/cc @SocialcastDevelopers #scgitx\"}" }
|
1142
|
+
context 'when use_pr_comments? is false' do
|
1143
|
+
it do
|
1144
|
+
expect_message message_body, :message_type => 'review_request'
|
1145
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-a', 'a']
|
1146
|
+
|
1147
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1148
|
+
expect(github_create_pr).to have_been_requested
|
1149
|
+
expect(github_assign_pr).to have_been_requested
|
1150
|
+
|
1151
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1152
|
+
end
|
992
1153
|
end
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1154
|
+
context 'when use_pr_comments? is true' do
|
1155
|
+
let(:use_pr_comments) { true }
|
1156
|
+
it do
|
1157
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-a', 'a']
|
1158
|
+
|
1159
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1160
|
+
expect(github_create_pr).to have_been_requested
|
1161
|
+
expect(github_assign_pr).to have_been_requested
|
1162
|
+
|
1163
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1164
|
+
end
|
1001
1165
|
end
|
1002
1166
|
end
|
1003
1167
|
context 'and a developer group is specified' do
|
1004
1168
|
let(:message_body) { "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 assigned to @JaneDoe\n\ntesting\n\n/cc @#{another_group} #scgitx\n\n1 file changed" }
|
1169
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest assigned to @JaneDoe \\n/cc @#{another_group} #scgitx\"}" }
|
1005
1170
|
let(:another_group) { 'AnotherDeveloperGroup' }
|
1006
1171
|
before do
|
1007
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:changelog_summary).and_return('1 file changed')
|
1008
1172
|
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return({'developer_group' => another_group})
|
1009
|
-
stub_message message_body, :message_type => 'review_request'
|
1010
|
-
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1011
1173
|
end
|
1012
|
-
|
1174
|
+
context 'when use_pr_comments? is false' do
|
1175
|
+
it do
|
1176
|
+
expect_message message_body, :message_type => 'review_request'
|
1177
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1178
|
+
expect(github_create_pr).to have_been_requested
|
1179
|
+
expect(github_assign_pr).to have_been_requested
|
1180
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1181
|
+
end
|
1182
|
+
end
|
1183
|
+
context 'when use_pr_comments? is true' do
|
1184
|
+
let(:use_pr_comments) { true }
|
1185
|
+
it do
|
1186
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1187
|
+
expect(github_create_pr).to have_been_requested
|
1188
|
+
expect(github_assign_pr).to have_been_requested
|
1189
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1190
|
+
end
|
1191
|
+
end
|
1013
1192
|
end
|
1014
1193
|
context 'and additional reviewers are not specified' do
|
1015
1194
|
let(:message_body) { "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 assigned to @JaneDoe\n\ntesting\n\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed" }
|
1195
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest assigned to @JaneDoe \\n/cc @SocialcastDevelopers #scgitx\"}" }
|
1196
|
+
context 'when use_pr_comments? is false' do
|
1197
|
+
it do
|
1198
|
+
expect_message message_body, :message_type => 'review_request'
|
1199
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1200
|
+
expect(github_create_pr).to have_been_requested
|
1201
|
+
expect(github_assign_pr).to have_been_requested
|
1202
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1203
|
+
end
|
1204
|
+
end
|
1205
|
+
context 'when use_pr_comments? is true' do
|
1206
|
+
let(:use_pr_comments) { true }
|
1207
|
+
it do
|
1208
|
+
Socialcast::Gitx::CLI.start ['reviewrequest', '--description', 'testing', '-s']
|
1209
|
+
expect(github_create_pr).to have_been_requested
|
1210
|
+
expect(github_assign_pr).to have_been_requested
|
1211
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1212
|
+
end
|
1213
|
+
end
|
1214
|
+
end
|
1215
|
+
end
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
describe '#createpr' do
|
1219
|
+
let!(:github_pr_create) do
|
1220
|
+
stub_request(:post, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls")
|
1221
|
+
.to_return(:status => 200, :body => %q({"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://api.github.com/repos/repo/project/issues/1"}), :headers => {})
|
1222
|
+
end
|
1223
|
+
it do
|
1224
|
+
Socialcast::Gitx::CLI.start ['createpr', '--description', 'testing']
|
1225
|
+
|
1226
|
+
expect(stubbed_executed_commands).to eq git_update_commands
|
1227
|
+
expect(github_pr_create).to have_been_requested
|
1228
|
+
end
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
describe '#assignpr' do
|
1232
|
+
let!(:github_find_pr_for_branch) do
|
1233
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls?head=socialcast:FOO")
|
1234
|
+
.to_return(:status => 200, :body => %q([{"html_url": "http://github.com/repo/project/pulls/1", "issue_url": "http://api.github.com/repos/repo/project/issues/1", "body":"testing"}]), :headers => {})
|
1235
|
+
end
|
1236
|
+
let(:stub_github_create_pr_comment) do
|
1237
|
+
stub_request(:post, "http://api.github.com/repos/repo/project/issues/1/comments")
|
1238
|
+
.with(:body => pr_comment_body)
|
1239
|
+
.to_return(:status => 200, :body => "{}", :headers => {})
|
1240
|
+
end
|
1241
|
+
let(:use_pr_comments) { false }
|
1242
|
+
before do
|
1243
|
+
stub_github_create_pr_comment
|
1244
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:use_pr_comments?).and_return(use_pr_comments)
|
1245
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:changelog_summary).and_return('1 file changed')
|
1246
|
+
end
|
1247
|
+
context 'when there are no review_buddies specified' do
|
1248
|
+
before do
|
1249
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config_file).and_return(Pathname(''))
|
1250
|
+
end
|
1251
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest \\n/cc @SocialcastDevelopers #scgitx\"}" }
|
1252
|
+
context 'when use_pr_comments? is false' do
|
1253
|
+
it do
|
1254
|
+
expect_message "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 \n\ntesting\n\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed", :message_type => 'review_request'
|
1255
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-s']
|
1256
|
+
|
1257
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1258
|
+
expect(github_find_pr_for_branch).to have_been_requested
|
1259
|
+
|
1260
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1261
|
+
end
|
1262
|
+
end
|
1263
|
+
context 'when use_pr_comments? is true' do
|
1264
|
+
let(:use_pr_comments) { true }
|
1265
|
+
it do
|
1266
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-s']
|
1267
|
+
|
1268
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1269
|
+
expect(github_find_pr_for_branch).to have_been_requested
|
1270
|
+
|
1271
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1272
|
+
end
|
1273
|
+
end
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
context 'when review_buddies are specified via a /config YML file' do
|
1277
|
+
let!(:github_assign_pr) { stub_request(:patch, "http://api.github.com/repos/repo/project/issues/1").to_return(:status => 200) }
|
1278
|
+
before do
|
1279
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:socialcast_review_buddy).and_return('JaneDoe')
|
1280
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:github_review_buddy).and_return('janedoe')
|
1281
|
+
end
|
1282
|
+
context 'and additional reviewers are specified' do
|
1283
|
+
let(:message_body) { "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 assigned to @JaneDoe\n\ntesting\n\nAssigned additionally to @JohnSmith for API review\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed" }
|
1284
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest assigned to @JaneDoe \\nAssigned additionally to @JohnSmith for API review \\n/cc @SocialcastDevelopers #scgitx\"}" }
|
1285
|
+
context 'when use_pr_comments? is false' do
|
1286
|
+
it do
|
1287
|
+
expect_message message_body, :message_type => 'review_request'
|
1288
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-a', 'a']
|
1289
|
+
|
1290
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1291
|
+
expect(github_assign_pr).to have_been_requested
|
1292
|
+
|
1293
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1294
|
+
end
|
1295
|
+
end
|
1296
|
+
context 'when use_pr_comments? is true' do
|
1297
|
+
let(:use_pr_comments) { true }
|
1298
|
+
it do
|
1299
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-a', 'a']
|
1300
|
+
|
1301
|
+
expect(stubbed_executed_commands).to eq(git_update_commands)
|
1302
|
+
expect(github_assign_pr).to have_been_requested
|
1303
|
+
|
1304
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1305
|
+
end
|
1306
|
+
end
|
1307
|
+
end
|
1308
|
+
context 'and a developer group is specified' do
|
1309
|
+
let(:message_body) { "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 assigned to @JaneDoe\n\ntesting\n\n/cc @#{another_group} #scgitx\n\n1 file changed" }
|
1310
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest assigned to @JaneDoe \\n/cc @#{another_group} #scgitx\"}" }
|
1311
|
+
let(:another_group) { 'AnotherDeveloperGroup' }
|
1016
1312
|
before do
|
1017
|
-
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:
|
1018
|
-
|
1019
|
-
|
1313
|
+
allow_any_instance_of(Socialcast::Gitx::CLI).to receive(:config).and_return({'developer_group' => another_group})
|
1314
|
+
end
|
1315
|
+
context 'when use_pr_comments? is false' do
|
1316
|
+
it do
|
1317
|
+
expect_message message_body, :message_type => 'review_request'
|
1318
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-s']
|
1319
|
+
expect(github_assign_pr).to have_been_requested
|
1320
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1321
|
+
end
|
1322
|
+
end
|
1323
|
+
context 'when use_pr_comments? is true' do
|
1324
|
+
let(:use_pr_comments) { true }
|
1325
|
+
it do
|
1326
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-s']
|
1327
|
+
expect(github_assign_pr).to have_been_requested
|
1328
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1329
|
+
end
|
1330
|
+
end
|
1331
|
+
end
|
1332
|
+
context 'and additional reviewers are not specified' do
|
1333
|
+
let(:message_body) { "#reviewrequest for FOO in socialcast/socialcast-git-extensions\nPR http://github.com/repo/project/pulls/1 assigned to @JaneDoe\n\ntesting\n\n/cc @SocialcastDevelopers #scgitx\n\n1 file changed" }
|
1334
|
+
let(:pr_comment_body) { "{\"body\":\"#reviewrequest assigned to @JaneDoe \\n/cc @SocialcastDevelopers #scgitx\"}" }
|
1335
|
+
context 'when use_pr_comments? is false' do
|
1336
|
+
it do
|
1337
|
+
expect_message message_body, :message_type => 'review_request'
|
1338
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-s']
|
1339
|
+
expect(github_assign_pr).to have_been_requested
|
1340
|
+
expect(stub_github_create_pr_comment).to_not have_been_requested
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
context 'when use_pr_comments? is true' do
|
1344
|
+
let(:use_pr_comments) { true }
|
1345
|
+
it do
|
1346
|
+
Socialcast::Gitx::CLI.start ['assignpr', '-s']
|
1347
|
+
expect(github_assign_pr).to have_been_requested
|
1348
|
+
expect(stub_github_create_pr_comment).to have_been_requested
|
1349
|
+
end
|
1020
1350
|
end
|
1021
|
-
it 'should create github pull request' do end # see expectations
|
1022
1351
|
end
|
1023
1352
|
end
|
1024
1353
|
end
|
1025
1354
|
|
1026
1355
|
describe '#promote' do
|
1027
1356
|
before do
|
1028
|
-
|
1029
|
-
|
1357
|
+
stub_request(:get, "https://api.github.com/repos/socialcast/socialcast-git-extensions/pulls?head=socialcast:FOO")
|
1358
|
+
.to_return(:status => 200, :body => "[]", :headers => {})
|
1030
1359
|
end
|
1031
|
-
|
1032
|
-
|
1360
|
+
let(:staging_integration_commands) do
|
1361
|
+
[
|
1033
1362
|
"git pull origin FOO",
|
1034
1363
|
"git pull origin master",
|
1035
1364
|
"git push origin HEAD",
|
@@ -1046,7 +1375,12 @@ describe Socialcast::Gitx::CLI do
|
|
1046
1375
|
"git push origin HEAD",
|
1047
1376
|
"git checkout staging",
|
1048
1377
|
"git checkout FOO"
|
1049
|
-
]
|
1378
|
+
]
|
1379
|
+
end
|
1380
|
+
it do
|
1381
|
+
expect_message "#worklog integrating FOO into staging in socialcast/socialcast-git-extensions #scgitx\n/cc @SocialcastDevelopers"
|
1382
|
+
Socialcast::Gitx::CLI.start ['promote']
|
1383
|
+
expect(stubbed_executed_commands).to eq staging_integration_commands
|
1050
1384
|
end
|
1051
1385
|
end
|
1052
1386
|
|
@@ -1056,7 +1390,7 @@ describe Socialcast::Gitx::CLI do
|
|
1056
1390
|
expect_any_instance_of(Socialcast::Gitx::CLI).to receive(:branches).with(:merged => true).and_return(['staging', 'bazquux', 'last_known_good_prototype'])
|
1057
1391
|
Socialcast::Gitx::CLI.start ['cleanup']
|
1058
1392
|
end
|
1059
|
-
it '
|
1393
|
+
it 'only cleans up non-reserved branches' do
|
1060
1394
|
expect(stubbed_executed_commands).to eq([
|
1061
1395
|
"git checkout master",
|
1062
1396
|
"git pull",
|