gitcycle 0.2.19 → 0.2.20
Sign up to get free protection for your applications and to get access to all the features.
- data/features/branch.feature +3 -3
- data/features/checkout.feature +20 -1
- data/features/discuss.feature +1 -0
- data/features/push.feature +23 -0
- data/features/ready.feature +40 -0
- data/features/steps/gitcycle_steps.rb +20 -12
- data/gitcycle.gemspec +1 -1
- data/lib/gitcycle.rb +27 -31
- metadata +6 -4
data/features/branch.feature
CHANGED
@@ -85,12 +85,12 @@ Scenario: Collaborator
|
|
85
85
|
Your work will eventually merge into 'master'. Is this correct? (y/n)
|
86
86
|
What branch would you like to eventually merge into?
|
87
87
|
Retrieving branch information from gitcycle.
|
88
|
-
Would you like to name your branch '
|
88
|
+
Would you like to name your branch 'ticket.id'? (y/n)
|
89
89
|
Adding remote repo 'config.owner/config.repo'.
|
90
90
|
Fetching remote 'config.owner'.
|
91
|
-
Checking out remote branch '
|
91
|
+
Checking out remote branch 'ticket.id' from 'config.owner/config.repo/some_branch'.
|
92
92
|
Fetching remote 'origin'.
|
93
|
-
Pushing 'origin/
|
93
|
+
Pushing 'origin/ticket.id'.
|
94
94
|
Sending branch information to gitcycle.
|
95
95
|
"""
|
96
96
|
And redis entries valid
|
data/features/checkout.feature
CHANGED
@@ -24,4 +24,23 @@ Scenario: Fresh repo
|
|
24
24
|
Retrieving branch information from gitcycle.
|
25
25
|
Tracking branch 'origin/master-last_ticket.id'.
|
26
26
|
"""
|
27
|
-
And current branch is "master-last_ticket.id"
|
27
|
+
And current branch is "master-last_ticket.id"
|
28
|
+
|
29
|
+
Scenario: Collaborator
|
30
|
+
Given a fresh set of repositories
|
31
|
+
When I cd to the owner repo
|
32
|
+
And I execute gitcycle branch with a new URL or string
|
33
|
+
And I give default input
|
34
|
+
And gitcycle runs
|
35
|
+
And I cd to the user repo
|
36
|
+
And I execute gitcycle with "co config.owner/master-ticket.id"
|
37
|
+
And gitcycle runs
|
38
|
+
Then output includes
|
39
|
+
"""
|
40
|
+
Adding remote repo 'config.owner/config.repo'.
|
41
|
+
Fetching remote 'config.owner'.
|
42
|
+
Creating branch 'master-ticket.id' from 'br/master-ticket.id'.
|
43
|
+
Sending branch information to gitcycle.
|
44
|
+
Checking out 'master-ticket.id'.
|
45
|
+
"""
|
46
|
+
And current branch is "master-ticket.id"
|
data/features/discuss.feature
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: Push
|
2
|
+
|
3
|
+
Scenario: Collaborator
|
4
|
+
Given a fresh set of repositories
|
5
|
+
When I cd to the owner repo
|
6
|
+
And I execute gitcycle branch with a new URL or string
|
7
|
+
And I give default input
|
8
|
+
And gitcycle runs
|
9
|
+
And I cd to the user repo
|
10
|
+
And I execute gitcycle with "co config.owner/master-ticket.id"
|
11
|
+
And gitcycle runs
|
12
|
+
And I commit something
|
13
|
+
And I execute gitcycle with "push"
|
14
|
+
And gitcycle runs
|
15
|
+
Then output includes
|
16
|
+
"""
|
17
|
+
Retrieving branch information from gitcycle.
|
18
|
+
Adding remote repo 'config.owner/config.repo'.
|
19
|
+
Fetching remote 'config.owner'.
|
20
|
+
Merging remote branch 'master-ticket.id' from 'config.owner/config.repo'.
|
21
|
+
Pushing branch 'config.owner/master-ticket.id'.
|
22
|
+
"""
|
23
|
+
And current branch is "master-ticket.id"
|
data/features/ready.feature
CHANGED
@@ -21,6 +21,45 @@ Scenario: Ready issue
|
|
21
21
|
Creating GitHub pull request.
|
22
22
|
Labeling issue as 'Pending Review'.
|
23
23
|
"""
|
24
|
+
And output includes "Opening issue" with URL
|
25
|
+
And URL is a valid issue
|
26
|
+
|
27
|
+
Scenario: Reopen pull request
|
28
|
+
Given a fresh set of repositories
|
29
|
+
When I cd to the user repo
|
30
|
+
And I execute gitcycle branch with a new URL or string
|
31
|
+
And I give default input
|
32
|
+
And gitcycle runs
|
33
|
+
And I commit something
|
34
|
+
And I execute gitcycle with "ready"
|
35
|
+
And gitcycle runs
|
36
|
+
And I cd to the owner repo
|
37
|
+
And I checkout master
|
38
|
+
And I execute gitcycle with "qa pass issue.id"
|
39
|
+
And I enter "y"
|
40
|
+
And gitcycle runs
|
41
|
+
And I wait for 5 seconds
|
42
|
+
And I cd to the user repo
|
43
|
+
And I checkout master-ticket.id
|
44
|
+
And I commit something
|
45
|
+
And I wait for 5 seconds
|
46
|
+
And I execute gitcycle with "ready"
|
47
|
+
And gitcycle runs
|
48
|
+
Then output includes
|
49
|
+
"""
|
50
|
+
Retrieving branch information from gitcycle.
|
51
|
+
Adding remote repo 'config.owner/config.repo'.
|
52
|
+
Fetching remote 'config.owner'.
|
53
|
+
Merging remote branch 'master' from 'config.owner/config.repo'.
|
54
|
+
Adding remote repo 'config.user/config.repo'.
|
55
|
+
Fetching remote 'config.user'.
|
56
|
+
Merging remote branch 'master-ticket.id' from 'config.user/config.repo'.
|
57
|
+
Creating GitHub pull request.
|
58
|
+
Labeling issue as 'Pending Review'.
|
59
|
+
"""
|
60
|
+
And output includes "Opening issue" with URL
|
61
|
+
And URL is a valid issue
|
62
|
+
And URL is not the same as the last
|
24
63
|
|
25
64
|
Scenario: Collaborator
|
26
65
|
Given a fresh set of repositories
|
@@ -42,5 +81,6 @@ Scenario: Collaborator
|
|
42
81
|
Retrieving branch information from gitcycle.
|
43
82
|
Adding remote repo 'config.owner/config.repo'.
|
44
83
|
Fetching remote 'config.owner'.
|
84
|
+
Merging remote branch 'some_branch' from 'config.owner/gitcycle_test'.
|
45
85
|
Pushing branch 'config.owner/some_branch'.
|
46
86
|
"""
|
@@ -18,6 +18,7 @@ $redis = Redis.new
|
|
18
18
|
|
19
19
|
Before do |scenario|
|
20
20
|
Launchy.stub :open do |url|
|
21
|
+
$last_url = $url
|
21
22
|
if url =~ /https:\/\/github.com\/.+\/issues\/\d+/
|
22
23
|
$github_url = url
|
23
24
|
end
|
@@ -51,12 +52,12 @@ def config(reload=false)
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def gsub_variables(str)
|
54
|
-
if $ticket
|
55
|
-
str = str.gsub('ticket.id', $ticket.attributes['id'])
|
56
|
-
end
|
57
55
|
if $tickets
|
58
56
|
str = str.gsub('last_ticket.id', $tickets.last.attributes['id'])
|
59
57
|
end
|
58
|
+
if $ticket
|
59
|
+
str = str.gsub('ticket.id', $ticket.attributes['id'])
|
60
|
+
end
|
60
61
|
if $github_url
|
61
62
|
issue_id = $github_url.match(/https:\/\/github.com\/.+\/issues\/(\d+)/)[1]
|
62
63
|
str = str.gsub('issue.id', issue_id)
|
@@ -151,9 +152,6 @@ def run_gitcycle(cmd)
|
|
151
152
|
@output << "#{str}\n"
|
152
153
|
puts str
|
153
154
|
end
|
154
|
-
if @scenario_title.include?('Collaborator')
|
155
|
-
@gitcycle.stub(:collab?).and_return(true)
|
156
|
-
end
|
157
155
|
if cmd
|
158
156
|
@gitcycle.start(Shellwords.split(cmd))
|
159
157
|
else
|
@@ -253,6 +251,16 @@ When /^gitcycle runs$/ do
|
|
253
251
|
run_gitcycle($execute.shift) until $execute.empty?
|
254
252
|
end
|
255
253
|
|
254
|
+
When /^I resolve the conflict/ do
|
255
|
+
$commit_msg = "#{@scenario_title} - #{rand}"
|
256
|
+
File.open('README', 'w') {|f| f.write($commit_msg) }
|
257
|
+
end
|
258
|
+
|
259
|
+
When /^I wait for (.+) seconds/ do |seconds|
|
260
|
+
$stdout.puts "Waiting #{seconds} seconds..."
|
261
|
+
sleep seconds.to_i
|
262
|
+
end
|
263
|
+
|
256
264
|
Then /^gitcycle runs with exit$/ do
|
257
265
|
$execute.each do |cmd|
|
258
266
|
lambda { run_gitcycle(cmd) }.should raise_error SystemExit
|
@@ -292,12 +300,7 @@ end
|
|
292
300
|
|
293
301
|
Then /^redis entries valid$/ do
|
294
302
|
collab = @scenario_title.include?('Collaborator')
|
295
|
-
before =
|
296
|
-
if collab
|
297
|
-
"br-some_branch-"
|
298
|
-
else
|
299
|
-
"master-"
|
300
|
-
end
|
303
|
+
before = collab ? "" : "master-"
|
301
304
|
after =
|
302
305
|
if @scenario_title.include?('Custom branch name')
|
303
306
|
"-rename"
|
@@ -327,6 +330,7 @@ Then /^redis entries valid$/ do
|
|
327
330
|
'user' => config['user'],
|
328
331
|
'source' => collab ? 'some_branch' : 'master'
|
329
332
|
}
|
333
|
+
should['collab'] = '1' if collab
|
330
334
|
if @scenario_title.include?("(Discuss)") && @scenario_title.include?("something committed")
|
331
335
|
should['labels'] = 'Branch - master'
|
332
336
|
should['issue_url'] = $github_url
|
@@ -344,4 +348,8 @@ end
|
|
344
348
|
|
345
349
|
Then /^URL is a valid issue$/ do
|
346
350
|
$github_url.should =~ /https:\/\/github.com\/.+\/issues\/\d+/
|
351
|
+
end
|
352
|
+
|
353
|
+
Then /^URL is not the same as the last$/ do
|
354
|
+
$last_url.should_not == $url
|
347
355
|
end
|
data/gitcycle.gemspec
CHANGED
data/lib/gitcycle.rb
CHANGED
@@ -71,17 +71,19 @@ class Gitcycle
|
|
71
71
|
params['branch[source]'] = q("What branch would you like to eventually merge into?")
|
72
72
|
end
|
73
73
|
|
74
|
+
source = params['branch[source]']
|
75
|
+
if source.include?('/')
|
76
|
+
params['branch[home]'], params['branch[source]'] = source.split('/')
|
77
|
+
params['branch[collab]'] = 1
|
78
|
+
end
|
79
|
+
|
74
80
|
puts "\nRetrieving branch information from gitcycle.\n".green
|
75
81
|
branch = get('branch', params)
|
76
82
|
name = branch['name']
|
77
83
|
|
78
84
|
begin
|
79
85
|
owner, repo = branch['repo'].split(':')
|
80
|
-
branch['home']
|
81
|
-
|
82
|
-
if branch['source'].include?('/')
|
83
|
-
branch['home'], branch['source'] = branch['source'].split('/')
|
84
|
-
end
|
86
|
+
branch['home'] ||= @git_login
|
85
87
|
|
86
88
|
unless yes?("Would you like to name your branch '#{name}'?")
|
87
89
|
name = q("\nWhat would you like to name your branch?")
|
@@ -89,7 +91,7 @@ class Gitcycle
|
|
89
91
|
end
|
90
92
|
|
91
93
|
checkout_remote_branch(
|
92
|
-
:owner => owner,
|
94
|
+
:owner => branch['collab'] ? branch['home'] : owner,
|
93
95
|
:repo => repo,
|
94
96
|
:branch => branch['source'],
|
95
97
|
:target => name
|
@@ -115,13 +117,13 @@ class Gitcycle
|
|
115
117
|
end
|
116
118
|
|
117
119
|
def checkout(*args)
|
118
|
-
if args.length
|
120
|
+
if args.length != 1 || options?(args)
|
119
121
|
exec_git(:checkout, args)
|
120
122
|
end
|
121
123
|
|
122
124
|
require_git && require_config
|
123
125
|
|
124
|
-
if args
|
126
|
+
if args[0] =~ /^https?:\/\//
|
125
127
|
puts "\nRetrieving branch information from gitcycle.\n".green
|
126
128
|
branch = get('branch', 'branch[lighthouse_url]' => args[0], 'create' => 0)
|
127
129
|
if branch
|
@@ -131,7 +133,7 @@ class Gitcycle
|
|
131
133
|
puts "\nDid you mean: gitc branch #{args[0]}\n".yellow
|
132
134
|
end
|
133
135
|
else
|
134
|
-
remote, branch = args
|
136
|
+
remote, branch = args[0].split('/')
|
135
137
|
remote, branch = nil, remote if branch.nil?
|
136
138
|
|
137
139
|
unless branches(:match => branch)
|
@@ -156,6 +158,8 @@ class Gitcycle
|
|
156
158
|
get('branch',
|
157
159
|
'branch[home]' => remote,
|
158
160
|
'branch[name]' => branch,
|
161
|
+
'branch[source]' => branch,
|
162
|
+
'branch[collab]' => 1,
|
159
163
|
'create' => 1
|
160
164
|
)
|
161
165
|
end
|
@@ -246,12 +250,12 @@ class Gitcycle
|
|
246
250
|
'create' => 0
|
247
251
|
)
|
248
252
|
|
249
|
-
if collab
|
253
|
+
if branch && branch['collab']
|
250
254
|
# Merge from collab
|
251
255
|
merge_remote_branch(
|
252
256
|
:owner => branch['home'],
|
253
257
|
:repo => branch['repo']['name'],
|
254
|
-
:branch => branch['
|
258
|
+
:branch => branch['source']
|
255
259
|
)
|
256
260
|
elsif branch
|
257
261
|
# Merge from upstream source branch
|
@@ -272,7 +276,7 @@ class Gitcycle
|
|
272
276
|
)
|
273
277
|
end
|
274
278
|
|
275
|
-
unless collab
|
279
|
+
unless branch && branch['collab']
|
276
280
|
# Merge from origin
|
277
281
|
merge_remote_branch(
|
278
282
|
:owner => @git_login,
|
@@ -289,11 +293,15 @@ class Gitcycle
|
|
289
293
|
|
290
294
|
require_git && require_config
|
291
295
|
|
292
|
-
pull
|
293
|
-
branch = branches(:current => true)
|
296
|
+
branch = pull
|
294
297
|
|
295
|
-
|
296
|
-
|
298
|
+
if branch['collab']
|
299
|
+
puts "\nPushing branch '#{branch['home']}/#{branch['name']}'.\n".green
|
300
|
+
run("git push #{branch['home']} #{branch['name']} -q")
|
301
|
+
else
|
302
|
+
puts "\nPushing branch 'origin/#{branch}'.\n".green
|
303
|
+
run("git push origin #{branch} -q")
|
304
|
+
end
|
297
305
|
end
|
298
306
|
|
299
307
|
def qa(*issues)
|
@@ -421,14 +429,14 @@ class Gitcycle
|
|
421
429
|
|
422
430
|
branch = pull
|
423
431
|
|
424
|
-
if branch && !collab
|
432
|
+
if branch && !branch['collab']
|
425
433
|
force = branch['labels'] && branch['labels'].include?('Pass')
|
426
434
|
branch = create_pull_request(branch, force)
|
427
435
|
end
|
428
436
|
|
429
437
|
if branch == false
|
430
438
|
puts "Branch not found.\n".red
|
431
|
-
elsif collab
|
439
|
+
elsif branch['collab']
|
432
440
|
remote, branch = branch['home'], branch['source']
|
433
441
|
puts "\nPushing branch '#{remote}/#{branch}'.\n".green
|
434
442
|
run("git push #{remote} #{branch} -q")
|
@@ -578,18 +586,6 @@ class Gitcycle
|
|
578
586
|
run("git push origin #{target} -q")
|
579
587
|
end
|
580
588
|
|
581
|
-
def collab?(branch)
|
582
|
-
return false unless branch
|
583
|
-
owner =
|
584
|
-
if branch['repo'].is_a?(::Hash)
|
585
|
-
branch['repo']['owner']
|
586
|
-
else
|
587
|
-
branch['repo'].split(':')[0]
|
588
|
-
end
|
589
|
-
branch['home'] != branch['user'] &&
|
590
|
-
branch['home'] != owner
|
591
|
-
end
|
592
|
-
|
593
589
|
def command_not_recognized
|
594
590
|
readme = "https://github.com/winton/gitcycle/blob/master/README.md"
|
595
591
|
puts "\nCommand not recognized.".red
|
@@ -793,7 +789,7 @@ class Gitcycle
|
|
793
789
|
|
794
790
|
if branches(:remote => true, :match => "#{owner}/#{branch}")
|
795
791
|
puts "\nMerging remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
|
796
|
-
run("git merge #{owner}/#{branch}
|
792
|
+
run("git merge #{owner}/#{branch}")
|
797
793
|
|
798
794
|
fix_conflict(options)
|
799
795
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitcycle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 20
|
10
|
+
version: 0.2.20
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-08-09 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- features/discuss.feature
|
157
157
|
- features/errors.feature
|
158
158
|
- features/pull.feature
|
159
|
+
- features/push.feature
|
159
160
|
- features/qa.feature
|
160
161
|
- features/ready.feature
|
161
162
|
- features/review.feature
|
@@ -206,6 +207,7 @@ test_files:
|
|
206
207
|
- features/discuss.feature
|
207
208
|
- features/errors.feature
|
208
209
|
- features/pull.feature
|
210
|
+
- features/push.feature
|
209
211
|
- features/qa.feature
|
210
212
|
- features/ready.feature
|
211
213
|
- features/review.feature
|