gitcycle 0.2.14 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/README.md +15 -8
- data/features/branch.feature +96 -0
- data/features/checkout.feature +27 -0
- data/features/{config.example.yml → config/config.example.yml} +0 -0
- data/features/discuss.feature +46 -0
- data/features/errors.feature +11 -0
- data/features/pull.feature +23 -0
- data/features/qa.feature +97 -0
- data/features/ready.feature +46 -0
- data/features/review.feature +27 -0
- data/features/setup.feature +7 -0
- data/features/steps/gitcycle_steps.rb +135 -44
- data/gitcycle.gemspec +1 -1
- data/lib/gitcycle.rb +109 -76
- metadata +24 -8
- data/features/gitcycle.feature +0 -231
@@ -17,10 +17,18 @@ require "gitcycle"
|
|
17
17
|
$redis = Redis.new
|
18
18
|
|
19
19
|
Before do |scenario|
|
20
|
+
Launchy.stub :open do |url|
|
21
|
+
if url =~ /https:\/\/github.com\/.+\/issues\/\d+/
|
22
|
+
$github_url = url
|
23
|
+
end
|
24
|
+
$url = url
|
25
|
+
end
|
26
|
+
|
20
27
|
@scenario_title = scenario.title
|
21
28
|
$execute = []
|
22
29
|
$input = []
|
23
30
|
$remotes = nil
|
31
|
+
$ticket = nil
|
24
32
|
end
|
25
33
|
|
26
34
|
def branches(options={})
|
@@ -36,7 +44,7 @@ end
|
|
36
44
|
|
37
45
|
def config(reload=false)
|
38
46
|
@config = nil if reload
|
39
|
-
@config ||= YAML.load(File.read("#{BASE}/features/config.yml"))
|
47
|
+
@config ||= YAML.load(File.read("#{BASE}/features/config/config.yml"))
|
40
48
|
Lighthouse.account = @config['lighthouse']['account']
|
41
49
|
Lighthouse.token = @config['lighthouse']['token']
|
42
50
|
@config
|
@@ -46,8 +54,11 @@ def gsub_variables(str)
|
|
46
54
|
if $ticket
|
47
55
|
str = str.gsub('ticket.id', $ticket.attributes['id'])
|
48
56
|
end
|
49
|
-
if $
|
50
|
-
|
57
|
+
if $tickets
|
58
|
+
str = str.gsub('last_ticket.id', $tickets.last.attributes['id'])
|
59
|
+
end
|
60
|
+
if $github_url
|
61
|
+
issue_id = $github_url.match(/https:\/\/github.com\/.+\/issues\/(\d+)/)[1]
|
51
62
|
str = str.gsub('issue.id', issue_id)
|
52
63
|
end
|
53
64
|
str = str.gsub('env.home', ENV['REPO'] == 'owner' ? config['owner'] : config['user'])
|
@@ -63,23 +74,73 @@ def log(match)
|
|
63
74
|
end
|
64
75
|
|
65
76
|
def repos(reload=false)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
fixtures = "#{BASE}/features/fixtures"
|
78
|
+
|
79
|
+
if !$repo_cache_created || !$repos || reload
|
80
|
+
Dir.chdir(fixtures)
|
81
|
+
end
|
82
|
+
|
83
|
+
if !$repo_cache_created || reload
|
84
|
+
$stdout.puts "Creating cached fixture repositories..."
|
85
|
+
|
75
86
|
system [
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"
|
87
|
+
"rm -rf #{fixtures}/owner_cache",
|
88
|
+
"rm -rf #{fixtures}/user_cache",
|
89
|
+
"mkdir -p #{fixtures}/owner_cache",
|
90
|
+
"cd #{fixtures}/owner_cache",
|
91
|
+
"git init . -q",
|
92
|
+
"git remote add origin git@github.com:#{config['owner']}/#{config['repo']}.git",
|
93
|
+
"echo 'first commit' > README",
|
94
|
+
"git add .",
|
95
|
+
"git commit -q -a -m 'First commit'",
|
96
|
+
"git push origin master --force -q",
|
97
|
+
"git fetch -q",
|
98
|
+
"cd #{fixtures}",
|
99
|
+
"rm -rf user_cache",
|
100
|
+
"cp -r owner_cache user_cache",
|
101
|
+
"cd user_cache",
|
102
|
+
"git remote rm origin",
|
103
|
+
"git remote add origin git@github.com:#{config['user']}/#{config['repo']}.git",
|
104
|
+
"git fetch -q",
|
105
|
+
"git push origin master --force -q"
|
79
106
|
].join(' && ')
|
80
107
|
|
81
|
-
$
|
108
|
+
unless $repo_cache_created
|
109
|
+
$stdout.puts "Clearing old fixture branches..."
|
110
|
+
|
111
|
+
[ 'owner', 'user' ].each do |type|
|
112
|
+
system(
|
113
|
+
"cd #{fixtures}/#{type}_cache && " +
|
114
|
+
[
|
115
|
+
"git branch -r",
|
116
|
+
"grep origin/",
|
117
|
+
"grep -v master$",
|
118
|
+
"grep -v HEAD",
|
119
|
+
"cut -d/ -f2-",
|
120
|
+
"while read line; do git push origin :$line -q; git branch -D $line; done;"
|
121
|
+
].join(' | ')
|
122
|
+
)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
$repo_cache_created = true
|
82
127
|
end
|
128
|
+
|
129
|
+
if !$repos || reload
|
130
|
+
$repos = {}
|
131
|
+
|
132
|
+
[ 'owner', 'user' ].each do |type|
|
133
|
+
FileUtils.rm_rf("#{fixtures}/#{type}")
|
134
|
+
$repos[type.to_sym] = "#{fixtures}/#{type}"
|
135
|
+
|
136
|
+
system [
|
137
|
+
"cd #{fixtures}",
|
138
|
+
"cp -R #{type}_cache #{type}"
|
139
|
+
].join(' && ')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
$repos
|
83
144
|
end
|
84
145
|
|
85
146
|
def run_gitcycle(cmd)
|
@@ -90,6 +151,9 @@ def run_gitcycle(cmd)
|
|
90
151
|
@output << "#{str}\n"
|
91
152
|
puts str
|
92
153
|
end
|
154
|
+
if @scenario_title.include?('Collaborator')
|
155
|
+
@gitcycle.stub(:collab?).and_return(true)
|
156
|
+
end
|
93
157
|
if cmd
|
94
158
|
@gitcycle.start(Shellwords.split(cmd))
|
95
159
|
else
|
@@ -105,15 +169,8 @@ Given /^a fresh set of repositories$/ do
|
|
105
169
|
repos(true)
|
106
170
|
end
|
107
171
|
|
108
|
-
|
109
|
-
|
110
|
-
:body => "test",
|
111
|
-
:project_id => config['lighthouse']['project'],
|
112
|
-
:state => "open",
|
113
|
-
:title => "Test ticket"
|
114
|
-
)
|
115
|
-
$ticket.save
|
116
|
-
$ticket.attributes['id'] = "master-#{$ticket.attributes['id']}"
|
172
|
+
When /^I create a new branch "([^\"]*)"$/ do |branch|
|
173
|
+
`git branch #{branch}`
|
117
174
|
end
|
118
175
|
|
119
176
|
When /^I execute gitcycle with nothing$/ do
|
@@ -124,6 +181,11 @@ When /^I execute gitcycle with "([^\"]*)"$/ do |cmd|
|
|
124
181
|
$execute << gsub_variables(cmd)
|
125
182
|
end
|
126
183
|
|
184
|
+
When /^I give default input$/ do
|
185
|
+
step "I enter \"y\""
|
186
|
+
step "I enter \"y\""
|
187
|
+
end
|
188
|
+
|
127
189
|
When /^I execute gitcycle setup$/ do
|
128
190
|
FileUtils.rm(GITCYCLE) if File.exists?(GITCYCLE)
|
129
191
|
$execute << [
|
@@ -140,10 +202,23 @@ When /^I execute gitcycle setup$/ do
|
|
140
202
|
].join(' ')
|
141
203
|
end
|
142
204
|
|
143
|
-
When /^I execute gitcycle (.*) with
|
205
|
+
When /^I execute gitcycle (.*) with a new URL or string$/ do |cmd|
|
206
|
+
$ticket = Lighthouse::Ticket.new(
|
207
|
+
:body => "test",
|
208
|
+
:project_id => config['lighthouse']['project'],
|
209
|
+
:state => "open",
|
210
|
+
:title => "Test ticket"
|
211
|
+
)
|
212
|
+
$ticket.save
|
213
|
+
$tickets ||= []
|
214
|
+
$tickets << $ticket
|
144
215
|
$execute << "#{cmd} #{$ticket.url}"
|
145
216
|
end
|
146
217
|
|
218
|
+
When /^I execute gitcycle (.*) with the last URL or string$/ do |cmd|
|
219
|
+
$execute << "#{cmd} #{$tickets.last.url}"
|
220
|
+
end
|
221
|
+
|
147
222
|
When /^I cd to the (.*) repo$/ do |user|
|
148
223
|
if ENV['REPO']
|
149
224
|
puts "(overiding repo as #{ENV['REPO']})"
|
@@ -160,19 +235,22 @@ When /^I commit something$/ do
|
|
160
235
|
branch = branches(:current => true)
|
161
236
|
$commit_msg = "#{@scenario_title} - #{rand}"
|
162
237
|
File.open('README', 'w') {|f| f.write($commit_msg) }
|
163
|
-
`git add . && git add . -u && git commit -a -m '#{$commit_msg}'`
|
164
|
-
`git push origin #{branch}`
|
238
|
+
`git add . && git add . -u && git commit -q -a -m '#{$commit_msg}'`
|
239
|
+
`git push origin #{branch} -q`
|
165
240
|
end
|
166
241
|
|
167
242
|
When /^I checkout (.+)$/ do |branch|
|
168
243
|
branch = gsub_variables(branch)
|
169
|
-
`git checkout #{branch}`
|
244
|
+
`git checkout #{branch} -q`
|
170
245
|
end
|
171
246
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
247
|
+
When /^I push (.+)$/ do |branch|
|
248
|
+
branch = gsub_variables(branch)
|
249
|
+
`git push origin #{branch} -q`
|
250
|
+
end
|
251
|
+
|
252
|
+
When /^gitcycle runs$/ do
|
253
|
+
run_gitcycle($execute.shift) until $execute.empty?
|
176
254
|
end
|
177
255
|
|
178
256
|
Then /^gitcycle runs with exit$/ do
|
@@ -198,12 +276,12 @@ end
|
|
198
276
|
|
199
277
|
Then /^output includes \"([^\"]*)" with URL$/ do |expected|
|
200
278
|
expected = gsub_variables(expected)
|
201
|
-
@output.
|
202
|
-
$url = @output.match(/#{expected}.*(https?:\/\/[^\s]+)/)[1]
|
279
|
+
@output.should =~ /#{expected}.*(https?:\/\/[^\s]+)/
|
203
280
|
end
|
204
281
|
|
205
282
|
Then /^output includes$/ do |expected|
|
206
283
|
expected = gsub_variables(expected).gsub('\t', "\t")
|
284
|
+
$stdout.puts expected
|
207
285
|
@output.gsub(/\n+/, "\n").include?(expected).should == true
|
208
286
|
end
|
209
287
|
|
@@ -213,7 +291,20 @@ Then /^output does not include \"([^\"]*)"$/ do |expected|
|
|
213
291
|
end
|
214
292
|
|
215
293
|
Then /^redis entries valid$/ do
|
216
|
-
|
294
|
+
collab = @scenario_title.include?('Collaborator')
|
295
|
+
before =
|
296
|
+
if collab
|
297
|
+
"br-some_branch-"
|
298
|
+
else
|
299
|
+
"master-"
|
300
|
+
end
|
301
|
+
after =
|
302
|
+
if @scenario_title.include?('Custom branch name')
|
303
|
+
"-rename"
|
304
|
+
else
|
305
|
+
""
|
306
|
+
end
|
307
|
+
ticket_id = "#{before}#{$ticket.attributes['id']}#{after}"
|
217
308
|
branch = $redis.hget(
|
218
309
|
[
|
219
310
|
"users",
|
@@ -222,22 +313,22 @@ Then /^redis entries valid$/ do
|
|
222
313
|
"#{config['owner']}:#{config['repo']}",
|
223
314
|
"branches"
|
224
315
|
].join('/'),
|
225
|
-
|
316
|
+
ticket_id
|
226
317
|
)
|
227
318
|
branch = Yajl::Parser.parse(branch)
|
228
319
|
should = {
|
229
320
|
'lighthouse_url' => $ticket.url,
|
230
321
|
'body' => "<div><p>test</p></div>\n\n#{$ticket.url}",
|
231
|
-
'home' => ENV['REPO'] == 'owner' ? config['owner'] : config['user'],
|
232
|
-
'name' =>
|
233
|
-
'id' =>
|
322
|
+
'home' => collab || ENV['REPO'] == 'owner' ? config['owner'] : config['user'],
|
323
|
+
'name' => ticket_id,
|
324
|
+
'id' => ticket_id,
|
234
325
|
'title' => $ticket.title,
|
235
326
|
'repo' => "#{config['owner']}:#{config['repo']}",
|
236
327
|
'user' => config['user'],
|
237
|
-
'source' => 'master'
|
328
|
+
'source' => collab ? 'some_branch' : 'master'
|
238
329
|
}
|
239
|
-
if @scenario_title == '
|
240
|
-
should['issue_url'] = $
|
330
|
+
if @scenario_title == 'No parameters and something committed'
|
331
|
+
should['issue_url'] = $github_url
|
241
332
|
end
|
242
333
|
branch.should == should
|
243
334
|
end
|
@@ -251,5 +342,5 @@ Then /^git log should contain the last commit$/ do
|
|
251
342
|
end
|
252
343
|
|
253
344
|
Then /^URL is a valid issue$/ do
|
254
|
-
$
|
345
|
+
$github_url.should =~ /https:\/\/github.com\/.+\/issues\/\d+/
|
255
346
|
end
|
data/gitcycle.gemspec
CHANGED
data/lib/gitcycle.rb
CHANGED
@@ -25,6 +25,8 @@ class Gitcycle
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize(args=nil)
|
28
|
+
$remotes = {}
|
29
|
+
|
28
30
|
if ENV['CONFIG']
|
29
31
|
@config_path = File.expand_path(ENV['CONFIG'])
|
30
32
|
else
|
@@ -65,6 +67,10 @@ class Gitcycle
|
|
65
67
|
exec_git(:branch, args)
|
66
68
|
end
|
67
69
|
|
70
|
+
unless yes?("\nYour work will eventually merge into '#{params['branch[source]']}'. Is this correct?")
|
71
|
+
params['branch[source]'] = q("What branch would you like to eventually merge into?")
|
72
|
+
end
|
73
|
+
|
68
74
|
puts "\nRetrieving branch information from gitcycle.\n".green
|
69
75
|
branch = get('branch', params)
|
70
76
|
name = branch['name']
|
@@ -73,8 +79,8 @@ class Gitcycle
|
|
73
79
|
owner, repo = branch['repo'].split(':')
|
74
80
|
branch['home'] = @git_login
|
75
81
|
|
76
|
-
|
77
|
-
branch['source'] =
|
82
|
+
if branch['source'].include?('/')
|
83
|
+
branch['home'], branch['source'] = branch['source'].split('/')
|
78
84
|
end
|
79
85
|
|
80
86
|
unless yes?("Would you like to name your branch '#{name}'?")
|
@@ -145,14 +151,13 @@ class Gitcycle
|
|
145
151
|
get('branch',
|
146
152
|
'branch[home]' => remote,
|
147
153
|
'branch[name]' => branch,
|
148
|
-
'branch[collab]' => 1,
|
149
154
|
'create' => 1
|
150
155
|
)
|
151
156
|
end
|
152
157
|
end
|
153
158
|
|
154
159
|
puts "Checking out '#{branch}'.\n".green
|
155
|
-
run("git checkout #{branch}")
|
160
|
+
run("git checkout -q #{branch}")
|
156
161
|
end
|
157
162
|
end
|
158
163
|
alias :co :checkout
|
@@ -236,9 +241,7 @@ class Gitcycle
|
|
236
241
|
'create' => 0
|
237
242
|
)
|
238
243
|
|
239
|
-
collab
|
240
|
-
|
241
|
-
if collab
|
244
|
+
if collab?(branch)
|
242
245
|
# Merge from collab
|
243
246
|
merge_remote_branch(
|
244
247
|
:owner => branch['home'],
|
@@ -264,7 +267,7 @@ class Gitcycle
|
|
264
267
|
)
|
265
268
|
end
|
266
269
|
|
267
|
-
unless collab
|
270
|
+
unless collab?(branch)
|
268
271
|
# Merge from origin
|
269
272
|
merge_remote_branch(
|
270
273
|
:owner => @git_login,
|
@@ -281,12 +284,11 @@ class Gitcycle
|
|
281
284
|
|
282
285
|
require_git && require_config
|
283
286
|
|
284
|
-
|
285
|
-
remote = branch && branch['collab'] == '1' ? branch['home'] : 'origin'
|
286
|
-
|
287
|
+
pull
|
287
288
|
branch = branches(:current => true)
|
288
|
-
|
289
|
-
|
289
|
+
|
290
|
+
puts "\nPushing branch 'origin/#{branch}'.\n".green
|
291
|
+
run("git push origin #{branch} -q")
|
290
292
|
end
|
291
293
|
|
292
294
|
def qa(*issues)
|
@@ -303,15 +305,31 @@ class Gitcycle
|
|
303
305
|
end
|
304
306
|
elsif issues.first == 'fail' || issues.first == 'pass'
|
305
307
|
branch = branches(:current => true)
|
306
|
-
|
307
|
-
|
308
|
-
|
308
|
+
pass_fail = issues.first
|
309
|
+
label = pass_fail.capitalize
|
310
|
+
issues = issues[1..-1]
|
311
|
+
|
312
|
+
if pass_fail == 'pass' && !issues.empty?
|
313
|
+
puts "\nWARNING: #{
|
314
|
+
issues.length == 1 ? "This issue" : "These issues"
|
315
|
+
} will merge straight into '#{branch}' without testing.\n".red
|
316
|
+
|
317
|
+
if yes?("Continue?")
|
318
|
+
qa_branch = create_qa_branch(
|
319
|
+
:instructions => false,
|
320
|
+
:issues => issues,
|
321
|
+
:source => branch
|
322
|
+
)
|
323
|
+
`git checkout qa_#{qa_branch['source']}_#{qa_branch['user']} -q`
|
324
|
+
$remotes = {}
|
325
|
+
qa('pass')
|
326
|
+
else
|
327
|
+
exit
|
328
|
+
end
|
329
|
+
elsif branch =~ /^qa_/
|
309
330
|
puts "\nRetrieving branch information from gitcycle.\n".green
|
310
331
|
qa_branch = get('qa_branch', :source => branch.gsub(/^qa_/, ''))
|
311
332
|
|
312
|
-
pass_fail = issues.first
|
313
|
-
issues = issues[1..-1]
|
314
|
-
|
315
333
|
if pass_fail == 'pass'
|
316
334
|
checkout_or_track(:name => qa_branch['source'], :remote => 'origin')
|
317
335
|
end
|
@@ -324,19 +342,18 @@ class Gitcycle
|
|
324
342
|
end
|
325
343
|
end
|
326
344
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
)
|
337
|
-
end
|
345
|
+
if pass_fail == 'pass' && issues.empty?
|
346
|
+
owner, repo = qa_branch['repo'].split(':')
|
347
|
+
merge_remote_branch(
|
348
|
+
:owner => owner,
|
349
|
+
:repo => repo,
|
350
|
+
:branch => "qa_#{qa_branch['source']}_#{qa_branch['user']}",
|
351
|
+
:type => :from_qa
|
352
|
+
)
|
353
|
+
end
|
338
354
|
|
339
|
-
|
355
|
+
unless issues.empty?
|
356
|
+
branches.each do |branch|
|
340
357
|
puts "\nLabeling issue #{branch['issue']} as '#{label}'.\n".green
|
341
358
|
get('label',
|
342
359
|
'qa_branch[source]' => qa_branch['source'],
|
@@ -371,7 +388,7 @@ class Gitcycle
|
|
371
388
|
run("git add . && git add . -u && git commit -a -F .git/MERGE_MSG")
|
372
389
|
|
373
390
|
puts "Pushing merge resolution of #{conflict['branch']} (issue ##{conflict['issue']}).\n".green
|
374
|
-
run("git push origin qa_#{qa_branch['source']}_#{qa_branch['user']}")
|
391
|
+
run("git push origin qa_#{qa_branch['source']}_#{qa_branch['user']} -q")
|
375
392
|
|
376
393
|
puts "\nDe-conflicting on gitcycle.\n".green
|
377
394
|
get('qa_branch',
|
@@ -397,31 +414,29 @@ class Gitcycle
|
|
397
414
|
def ready(*issues)
|
398
415
|
require_git && require_config
|
399
416
|
|
400
|
-
|
401
|
-
branch = pull
|
402
|
-
branch = create_pull_request(branch)
|
417
|
+
branch = pull
|
403
418
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
puts "\nLabeling issue as 'Pending Review'.\n".green
|
408
|
-
get('label',
|
409
|
-
'branch[name]' => branch['name'],
|
410
|
-
'labels' => [ 'Pending Review' ]
|
411
|
-
)
|
419
|
+
if branch && !collab?(branch)
|
420
|
+
branch = create_pull_request(branch)
|
421
|
+
end
|
412
422
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
423
|
+
if branch == false
|
424
|
+
puts "Branch not found.\n".red
|
425
|
+
elsif collab?(branch)
|
426
|
+
remote, branch = branch['home'], branch['source']
|
427
|
+
puts "\nPushing branch '#{remote}/#{branch}'.\n".green
|
428
|
+
run("git push #{remote} #{branch} -q")
|
429
|
+
elsif branch['issue_url']
|
430
|
+
puts "\nLabeling issue as 'Pending Review'.\n".green
|
420
431
|
get('label',
|
421
|
-
'
|
422
|
-
'labels' => [ 'Pending Review' ]
|
423
|
-
'scope' => 'repo'
|
432
|
+
'branch[name]' => branch['name'],
|
433
|
+
'labels' => [ 'Pending Review' ]
|
424
434
|
)
|
435
|
+
|
436
|
+
puts "Opening issue: #{branch['issue_url']}\n".green
|
437
|
+
Launchy.open(branch['issue_url'])
|
438
|
+
else
|
439
|
+
puts "You have not pushed any commits to '#{branch['name']}'.\n".red
|
425
440
|
end
|
426
441
|
end
|
427
442
|
|
@@ -483,8 +498,6 @@ class Gitcycle
|
|
483
498
|
owner = options[:owner]
|
484
499
|
repo = options[:repo]
|
485
500
|
|
486
|
-
$remotes ||= {}
|
487
|
-
|
488
501
|
unless $remotes[owner]
|
489
502
|
$remotes[owner] = true
|
490
503
|
|
@@ -514,14 +527,14 @@ class Gitcycle
|
|
514
527
|
|
515
528
|
if branches(:match => name)
|
516
529
|
puts "Checking out branch '#{name}'.\n".green
|
517
|
-
run("git checkout #{name}")
|
530
|
+
run("git checkout #{name} -q")
|
518
531
|
else
|
519
532
|
puts "Tracking branch '#{remote}/#{name}'.\n".green
|
520
533
|
run("git fetch -q #{remote}")
|
521
|
-
run("git checkout -b #{name} #{remote}/#{name}")
|
534
|
+
run("git checkout -q -b #{name} #{remote}/#{name}")
|
522
535
|
end
|
523
536
|
|
524
|
-
run("git pull #{remote} #{name}")
|
537
|
+
run("git pull #{remote} #{name} -q")
|
525
538
|
end
|
526
539
|
|
527
540
|
def checkout_remote_branch(options={})
|
@@ -532,12 +545,12 @@ class Gitcycle
|
|
532
545
|
|
533
546
|
if branches(:match => target)
|
534
547
|
if yes?("You already have a branch called '#{target}'. Overwrite?")
|
535
|
-
run("git push origin :#{target}")
|
536
|
-
run("git checkout master")
|
548
|
+
run("git push origin :#{target} -q")
|
549
|
+
run("git checkout master -q")
|
537
550
|
run("branch -D #{target}")
|
538
551
|
else
|
539
|
-
run("git checkout #{target}")
|
540
|
-
run("git pull origin #{target}")
|
552
|
+
run("git checkout #{target} -q")
|
553
|
+
run("git pull origin #{target} -q")
|
541
554
|
return
|
542
555
|
end
|
543
556
|
end
|
@@ -545,18 +558,30 @@ class Gitcycle
|
|
545
558
|
add_remote_and_fetch(options)
|
546
559
|
|
547
560
|
puts "Checking out remote branch '#{target}' from '#{owner}/#{repo}/#{branch}'.\n".green
|
548
|
-
run("git checkout -b #{target} #{owner}/#{branch}")
|
561
|
+
run("git checkout -q -b #{target} #{owner}/#{branch}")
|
549
562
|
|
550
563
|
puts "Fetching remote 'origin'.\n".green
|
551
564
|
run("git fetch -q origin")
|
552
565
|
|
553
566
|
if branches(:remote => true, :match => "origin/#{target}")
|
554
567
|
puts "Pulling 'origin/#{target}'.\n".green
|
555
|
-
run("git pull origin #{target}")
|
568
|
+
run("git pull origin #{target} -q")
|
556
569
|
end
|
557
570
|
|
558
571
|
puts "Pushing 'origin/#{target}'.\n".green
|
559
|
-
run("git push origin #{target}")
|
572
|
+
run("git push origin #{target} -q")
|
573
|
+
end
|
574
|
+
|
575
|
+
def collab?(branch)
|
576
|
+
return false unless branch
|
577
|
+
owner =
|
578
|
+
if branch['repo'].is_a?(::Hash)
|
579
|
+
branch['repo']['owner']
|
580
|
+
else
|
581
|
+
branch['repo'].split(':')[0]
|
582
|
+
end
|
583
|
+
branch['home'] != branch['user'] &&
|
584
|
+
branch['home'] != owner
|
560
585
|
end
|
561
586
|
|
562
587
|
def command_not_recognized
|
@@ -588,17 +613,21 @@ class Gitcycle
|
|
588
613
|
end
|
589
614
|
|
590
615
|
def create_qa_branch(options)
|
616
|
+
instructions = options[:instructions]
|
591
617
|
issues = options[:issues]
|
592
618
|
range = options[:range] || (0..-1)
|
619
|
+
source = options[:source]
|
593
620
|
|
594
621
|
if (issues && !issues.empty?) || options[:qa_branch]
|
595
622
|
if options[:qa_branch]
|
596
623
|
qa_branch = options[:qa_branch]
|
597
624
|
else
|
598
|
-
source
|
599
|
-
|
600
|
-
|
601
|
-
|
625
|
+
unless source
|
626
|
+
source = branches(:current => true)
|
627
|
+
|
628
|
+
unless yes?("\nDo you want to create a QA branch from '#{source}'?")
|
629
|
+
source = q("What branch would you like to base this QA branch off of?")
|
630
|
+
end
|
602
631
|
end
|
603
632
|
|
604
633
|
puts "\nRetrieving branch information from gitcycle.\n".green
|
@@ -613,10 +642,10 @@ class Gitcycle
|
|
613
642
|
if branches(:match => name, :all => true)
|
614
643
|
puts "Deleting old QA branch '#{name}'.\n".green
|
615
644
|
if branches(:match => name)
|
616
|
-
run("git checkout master")
|
645
|
+
run("git checkout master -q")
|
617
646
|
run("git branch -D #{name}")
|
618
647
|
end
|
619
|
-
run("git push origin :#{name}")
|
648
|
+
run("git push origin :#{name} -q")
|
620
649
|
end
|
621
650
|
|
622
651
|
checkout_remote_branch(
|
@@ -651,8 +680,10 @@ class Gitcycle
|
|
651
680
|
)
|
652
681
|
end
|
653
682
|
|
654
|
-
|
655
|
-
|
683
|
+
unless options[:instructions] == false
|
684
|
+
puts "\nType '".yellow + "gitc qa pass".green + "' to approve all issues in this branch.\n".yellow
|
685
|
+
puts "Type '".yellow + "gitc qa fail".red + "' to reject all issues in this branch.\n".yellow
|
686
|
+
end
|
656
687
|
|
657
688
|
unless warnings.empty?
|
658
689
|
puts "\n#{"WARNING:".red} If you pass this QA branch, the following branches will merge into '#{source.yellow}':\n"
|
@@ -665,6 +696,8 @@ class Gitcycle
|
|
665
696
|
puts "\nBe sure this is correct!\n".yellow
|
666
697
|
end
|
667
698
|
end
|
699
|
+
|
700
|
+
qa_branch
|
668
701
|
end
|
669
702
|
end
|
670
703
|
|
@@ -684,7 +717,7 @@ class Gitcycle
|
|
684
717
|
if $? != 0
|
685
718
|
puts "Conflict occurred when merging '#{branch}'#{" (issue ##{issue})" if issue}.\n".red
|
686
719
|
|
687
|
-
if type
|
720
|
+
if type == :to_qa
|
688
721
|
puts "Please resolve this conflict with '#{owner}'.\n".yellow
|
689
722
|
|
690
723
|
puts "\nSending conflict information to gitcycle.\n".green
|
@@ -696,7 +729,7 @@ class Gitcycle
|
|
696
729
|
elsif type # from_qa or to_qa
|
697
730
|
branch = branches(:current => true)
|
698
731
|
puts "Pushing branch '#{branch}'.\n".green
|
699
|
-
run("git push origin #{branch}")
|
732
|
+
run("git push origin #{branch} -q")
|
700
733
|
end
|
701
734
|
end
|
702
735
|
|
@@ -765,7 +798,7 @@ class Gitcycle
|
|
765
798
|
|
766
799
|
if branches(:remote => true, :match => "#{owner}/#{branch}")
|
767
800
|
puts "\nMerging remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
|
768
|
-
run("git merge #{owner}/#{branch}")
|
801
|
+
run("git merge #{owner}/#{branch} -q")
|
769
802
|
|
770
803
|
fix_conflict(options)
|
771
804
|
end
|