gitcycle 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +7 -3
- data/features/gitcycle.feature +74 -58
- data/features/steps/gitcycle_steps.rb +3 -3
- data/gitcycle.gemspec +1 -1
- data/lib/gitcycle.rb +45 -29
- metadata +4 -4
data/README.md
CHANGED
@@ -99,7 +99,11 @@ This will add a "pass" label to the issue and will complete the pull request by
|
|
99
99
|
Todo
|
100
100
|
----
|
101
101
|
|
102
|
+
* Make ticket active when starting branch
|
102
103
|
* Label issues with ticket milestone?
|
103
|
-
*
|
104
|
-
|
105
|
-
*
|
104
|
+
* Check for conflict whenever merge happens
|
105
|
+
* Instead of detecting CONFLICT, use error status $? != 0
|
106
|
+
* Add comment on lighthouse with issue URL
|
107
|
+
* Need to make sure when a branch is created, it is always from the pristine remote version, not local
|
108
|
+
* Add conflict check when calling "qa pass [ticket]"
|
109
|
+
* Need to change Github.parseLabels so we can have a "Fail" label along side a "Pending" tag, but for all other cases there should only be one of these tags present: "Pending QA", "Pending Review", "Pass"
|
data/features/gitcycle.feature
CHANGED
@@ -21,16 +21,24 @@ Scenario: Feature branch w/ custom branch name
|
|
21
21
|
And a new Lighthouse ticket
|
22
22
|
When I cd to the user repo
|
23
23
|
And I execute gitcycle with the Lighthouse ticket URL
|
24
|
+
And I enter "y"
|
24
25
|
And I enter "n"
|
25
26
|
And I enter "ticket.id-rename"
|
26
27
|
Then gitcycle runs
|
27
|
-
And output includes
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
And output includes
|
29
|
+
"""
|
30
|
+
Retrieving branch information from gitcycle.
|
31
|
+
Your work will eventually merge into 'master'. Is this correct? (y/n)
|
32
|
+
Adding remote repo 'br/gitcycle_test'.
|
33
|
+
Fetching remote repo 'br'.
|
34
|
+
Checking out remote branch 'master' from 'br/gitcycle_test'.
|
35
|
+
Would you like to name your branch 'ticket.id'? (y/n)
|
36
|
+
What would you like to name your branch?
|
37
|
+
Creating 'ticket.id-rename' from 'master'.
|
38
|
+
Checking out branch 'ticket.id-rename'.
|
39
|
+
Pushing 'ticket.id-rename'.
|
40
|
+
Sending branch information to gitcycle.
|
41
|
+
"""
|
34
42
|
And redis entries valid
|
35
43
|
|
36
44
|
Scenario: Feature branch
|
@@ -39,27 +47,32 @@ Scenario: Feature branch
|
|
39
47
|
When I cd to the user repo
|
40
48
|
And I execute gitcycle with the Lighthouse ticket URL
|
41
49
|
And I enter "y"
|
50
|
+
And I enter "y"
|
42
51
|
Then gitcycle runs
|
43
|
-
And output includes
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
And output includes
|
53
|
+
"""
|
54
|
+
Retrieving branch information from gitcycle.
|
55
|
+
Your work will eventually merge into 'master'. Is this correct? (y/n)
|
56
|
+
Adding remote repo 'br/gitcycle_test'.
|
57
|
+
Fetching remote repo 'br'.
|
58
|
+
Checking out remote branch 'master' from 'br/gitcycle_test'.
|
59
|
+
Would you like to name your branch 'ticket.id'? (y/n)
|
60
|
+
Creating 'ticket.id' from 'master'.
|
61
|
+
Checking out branch 'ticket.id'.
|
62
|
+
Pushing 'ticket.id'.
|
63
|
+
Sending branch information to gitcycle.
|
64
|
+
"""
|
50
65
|
And redis entries valid
|
51
66
|
|
52
67
|
Scenario: Checkout via ticket w/ existing branch
|
53
68
|
When I cd to the user repo
|
54
69
|
And I execute gitcycle with the Lighthouse ticket URL
|
55
70
|
Then gitcycle runs
|
56
|
-
And output includes
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
And output does not include "Pushing 'ticket.id'."
|
62
|
-
And output does not include "Sending branch information to gitcycle."
|
71
|
+
And output includes
|
72
|
+
"""
|
73
|
+
Retrieving branch information from gitcycle.
|
74
|
+
Checking out branch 'ticket.id'.
|
75
|
+
"""
|
63
76
|
And current branch is "ticket.id"
|
64
77
|
|
65
78
|
Scenario: Checkout via ticket w/ fresh repo
|
@@ -67,13 +80,11 @@ Scenario: Checkout via ticket w/ fresh repo
|
|
67
80
|
When I cd to the user repo
|
68
81
|
And I execute gitcycle with the Lighthouse ticket URL
|
69
82
|
Then gitcycle runs
|
70
|
-
And output includes
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
And output does not include "Pushing 'ticket.id'."
|
76
|
-
And output does not include "Sending branch information to gitcycle."
|
83
|
+
And output includes
|
84
|
+
"""
|
85
|
+
Retrieving branch information from gitcycle.
|
86
|
+
Tracking branch 'ticket.id'.
|
87
|
+
"""
|
77
88
|
And current branch is "ticket.id"
|
78
89
|
|
79
90
|
Scenario: Pull changes from upstream
|
@@ -84,10 +95,13 @@ Scenario: Pull changes from upstream
|
|
84
95
|
And I checkout ticket.id
|
85
96
|
And I execute gitcycle with "pull"
|
86
97
|
Then gitcycle runs
|
87
|
-
And output includes
|
88
|
-
|
89
|
-
|
90
|
-
|
98
|
+
And output includes
|
99
|
+
"""
|
100
|
+
Retrieving branch information from gitcycle.
|
101
|
+
Adding remote repo 'config.owner/config.repo'.
|
102
|
+
Fetching remote repo 'config.owner'.
|
103
|
+
Merging remote branch 'master' from 'config.owner/config.repo'.
|
104
|
+
"""
|
91
105
|
And git log should contain the last commit
|
92
106
|
|
93
107
|
Scenario: Discuss commits w/ no parameters and nothing committed
|
@@ -95,11 +109,12 @@ Scenario: Discuss commits w/ no parameters and nothing committed
|
|
95
109
|
And I checkout ticket.id
|
96
110
|
And I execute gitcycle with "discuss"
|
97
111
|
Then gitcycle runs
|
98
|
-
And output includes
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
112
|
+
And output includes
|
113
|
+
"""
|
114
|
+
Retrieving branch information from gitcycle.
|
115
|
+
Creating GitHub pull request.
|
116
|
+
You must push code before opening a pull request.
|
117
|
+
"""
|
103
118
|
And redis entries valid
|
104
119
|
|
105
120
|
Scenario: Discuss commits w/ no parameters and something committed
|
@@ -108,11 +123,12 @@ Scenario: Discuss commits w/ no parameters and something committed
|
|
108
123
|
And I commit something
|
109
124
|
And I execute gitcycle with "discuss"
|
110
125
|
Then gitcycle runs
|
111
|
-
And output includes
|
112
|
-
|
113
|
-
|
126
|
+
And output includes
|
127
|
+
"""
|
128
|
+
Retrieving branch information from gitcycle.
|
129
|
+
Creating GitHub pull request.
|
130
|
+
"""
|
114
131
|
And output includes "Opening issue" with URL
|
115
|
-
And output does not include "You must push code before opening a pull request."
|
116
132
|
And URL is a valid issue
|
117
133
|
And redis entries valid
|
118
134
|
|
@@ -154,20 +170,20 @@ Scenario: Reviewed issue w/ parameters
|
|
154
170
|
Then gitcycle runs
|
155
171
|
And output includes "Labeling issues as 'Pending QA'."
|
156
172
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
173
|
+
Scenario: QA issue
|
174
|
+
When I cd to the owner repo
|
175
|
+
And I checkout master
|
176
|
+
And I execute gitcycle with "qa issue.id"
|
177
|
+
Then gitcycle runs
|
178
|
+
And output includes
|
179
|
+
"""
|
180
|
+
Retrieving branch information from gitcycle.
|
181
|
+
Deleting old QA branch 'qa_master'.
|
182
|
+
Creating QA branch 'qa_master'.
|
183
|
+
Adding remote repo 'config.user/gitcycle_test'.
|
184
|
+
Fetching remote repo 'config.user'.
|
185
|
+
Merging remote branch 'ticket.id' from 'config.user/gitcycle_test'.
|
186
|
+
Pushing QA branch 'qa_master'.
|
187
|
+
Type 'gitc qa pass' to approve all issues in this branch.
|
188
|
+
Type 'gitc qa fail' to reject all issues in this branch.
|
189
|
+
"""
|
@@ -87,7 +87,7 @@ def run_gitcycle(cmd)
|
|
87
87
|
@gitcycle = Gitcycle.new
|
88
88
|
@gitcycle.stub(:puts) do |str|
|
89
89
|
str = str.gsub(/\e\[\d{1,2}m/, '')
|
90
|
-
@output << str
|
90
|
+
@output << "#{str}\n"
|
91
91
|
puts str
|
92
92
|
end
|
93
93
|
if cmd
|
@@ -197,12 +197,12 @@ end
|
|
197
197
|
|
198
198
|
Then /^output includes$/ do |expected|
|
199
199
|
expected = gsub_variables(expected)
|
200
|
-
@output.include?(expected).should == true
|
200
|
+
@output.gsub(/\n+/, "\n").include?(expected).should == true
|
201
201
|
end
|
202
202
|
|
203
203
|
Then /^output does not include \"([^\"]*)"$/ do |expected|
|
204
204
|
expected = gsub_variables(expected)
|
205
|
-
@output.
|
205
|
+
@output.include?(expected).should == false
|
206
206
|
end
|
207
207
|
|
208
208
|
Then /^redis entries valid$/ do
|
data/gitcycle.gemspec
CHANGED
data/lib/gitcycle.rb
CHANGED
@@ -56,18 +56,21 @@ class Gitcycle
|
|
56
56
|
branch = get('branch', params)
|
57
57
|
|
58
58
|
name = branch['name']
|
59
|
+
owner, repo = branch['repo'].split(':')
|
59
60
|
|
60
61
|
unless branch['exists']
|
61
62
|
branch['home'] = @git_login
|
62
63
|
branch['source'] = branches(:current => true)
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
unless yes?("Your work will eventually merge into '#{branch['source']}'. Is this correct?")
|
66
|
+
branch['source'] = q("What branch would you like to eventually merge into?")
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
checkout_remote_branch(
|
70
|
+
:owner => owner,
|
71
|
+
:repo => repo,
|
72
|
+
:branch => branch['source']
|
73
|
+
)
|
71
74
|
|
72
75
|
unless yes?("Would you like to name your branch '#{name}'?")
|
73
76
|
name = q("\nWhat would you like to name your branch?")
|
@@ -89,7 +92,7 @@ class Gitcycle
|
|
89
92
|
end
|
90
93
|
|
91
94
|
unless branch['exists']
|
92
|
-
puts "Pushing '#{name}'
|
95
|
+
puts "Pushing '#{name}'.\n".green
|
93
96
|
run("git push origin #{name}")
|
94
97
|
|
95
98
|
puts "Sending branch information to gitcycle.".green
|
@@ -173,11 +176,13 @@ class Gitcycle
|
|
173
176
|
|
174
177
|
puts "Checking out #{qa_branch['source']}.".green
|
175
178
|
run("git checkout #{qa_branch['source']}")
|
179
|
+
run("git pull origin #{qa_branch['source']}")
|
176
180
|
|
177
181
|
if issues[1..-1].empty?
|
178
182
|
if issues.first == 'pass'
|
179
183
|
puts "Merging '#{branch}' into '#{qa_branch['source']}'.\n".green
|
180
184
|
run("git merge #{branch}")
|
185
|
+
run("git pull origin #{qa_branch['source']}")
|
181
186
|
run("git push origin #{qa_branch['source']}")
|
182
187
|
end
|
183
188
|
|
@@ -329,6 +334,23 @@ class Gitcycle
|
|
329
334
|
|
330
335
|
private
|
331
336
|
|
337
|
+
def add_remote_and_fetch(options={})
|
338
|
+
owner = options[:owner]
|
339
|
+
repo = options[:repo]
|
340
|
+
|
341
|
+
$remotes ||= {}
|
342
|
+
|
343
|
+
unless $remotes[owner]
|
344
|
+
$remotes[owner] = true
|
345
|
+
puts "Adding remote repo '#{owner}/#{repo}'.\n".green
|
346
|
+
run("git remote rm #{owner}") if remotes(:match => owner)
|
347
|
+
run("git remote add #{owner} git@github.com:#{owner}/#{repo}.git")
|
348
|
+
end
|
349
|
+
|
350
|
+
puts "\nFetching remote repo '#{owner}'.\n".green
|
351
|
+
run("git fetch #{owner}")
|
352
|
+
end
|
353
|
+
|
332
354
|
def branches(options={})
|
333
355
|
b = `git branch#{" -a" if options[:all]}`
|
334
356
|
if options[:current]
|
@@ -345,20 +367,22 @@ class Gitcycle
|
|
345
367
|
repo = options[:repo]
|
346
368
|
branch = options[:branch]
|
347
369
|
|
348
|
-
|
370
|
+
add_remote_and_fetch(options)
|
371
|
+
|
372
|
+
puts "\nChecking out remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
|
349
373
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
run("git
|
354
|
-
run("git remote add #{owner} git@github.com:#{owner}/#{repo}.git")
|
374
|
+
if branches(:match => branch)
|
375
|
+
run("git checkout #{branch}")
|
376
|
+
else
|
377
|
+
run("git checkout -b #{branch} #{owner}/#{branch}")
|
355
378
|
end
|
356
|
-
|
357
|
-
puts "\nFetching remote branch '#{branch}'.\n".green
|
358
|
-
run("git fetch #{owner}")
|
359
379
|
|
360
|
-
|
361
|
-
|
380
|
+
if branches(:current => true) == branch
|
381
|
+
run("git pull #{owner} #{branch}")
|
382
|
+
else
|
383
|
+
puts "Oops. Something bad happened.\n".red
|
384
|
+
exit
|
385
|
+
end
|
362
386
|
end
|
363
387
|
|
364
388
|
def create_pull_request
|
@@ -408,6 +432,8 @@ class Gitcycle
|
|
408
432
|
run("git fetch && git checkout -b #{source} origin/#{source}")
|
409
433
|
end
|
410
434
|
|
435
|
+
run("git pull origin #{source}")
|
436
|
+
|
411
437
|
if branches(:match => name, :all => true)
|
412
438
|
puts "Deleting old QA branch '#{name}'.\n".green
|
413
439
|
run("git branch -D #{name}")
|
@@ -507,17 +533,7 @@ class Gitcycle
|
|
507
533
|
repo = options[:repo]
|
508
534
|
branch = options[:branch]
|
509
535
|
|
510
|
-
|
511
|
-
|
512
|
-
unless $remotes[owner]
|
513
|
-
$remotes[owner] = true
|
514
|
-
puts "Adding remote repo '#{owner}/#{repo}'.\n".green
|
515
|
-
run("git remote rm #{owner}") if remotes(:match => owner)
|
516
|
-
run("git remote add #{owner} git@github.com:#{owner}/#{repo}.git")
|
517
|
-
end
|
518
|
-
|
519
|
-
puts "\nFetching remote branch '#{branch}'.\n".green
|
520
|
-
run("git fetch #{owner}")
|
536
|
+
add_remote_and_fetch(options)
|
521
537
|
|
522
538
|
puts "\nMerging remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
|
523
539
|
run("git merge #{owner}/#{branch}")
|
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: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
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-01-
|
18
|
+
date: 2012-01-20 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|