gitcycle 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
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
- * Add confirmation when creating new dev branch for branch that it is based off of
104
- * If confirmation is a no, allow user to specify branch to base off of
105
- * bug with branch rename on Jimmy's machine
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"
@@ -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 "Retrieving branch information from gitcycle."
28
- And output includes "Would you like to name your branch 'ticket.id'?"
29
- And output includes "What would you like to name your branch?"
30
- And output includes "Creating 'ticket.id-rename' from 'master'."
31
- And output includes "Checking out branch 'ticket.id-rename'."
32
- And output includes "Pushing 'ticket.id-rename'."
33
- And output includes "Sending branch information to gitcycle."
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 "Retrieving branch information from gitcycle."
44
- And output includes "Would you like to name your branch 'ticket.id'?"
45
- And output does not include "What would you like to name your branch?"
46
- And output includes "Creating 'ticket.id' from 'master'."
47
- And output includes "Checking out branch 'ticket.id'."
48
- And output includes "Pushing 'ticket.id'."
49
- And output includes "Sending branch information to gitcycle."
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 "Retrieving branch information from gitcycle."
57
- And output does not include "Would you like to name your branch 'ticket.id'?"
58
- And output does not include "What would you like to name your branch?"
59
- And output does not include "Creating 'ticket.id' from 'master'."
60
- And output includes "Checking out branch 'ticket.id'."
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 "Retrieving branch information from gitcycle."
71
- And output does not include "Would you like to name your branch 'ticket.id'?"
72
- And output does not include "What would you like to name your branch?"
73
- And output does not include "Creating 'ticket.id' from 'master'."
74
- And output includes "Tracking branch 'ticket.id'."
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 "Retrieving branch information from gitcycle."
88
- And output includes "Adding remote repo 'config.owner/config.repo'."
89
- And output includes "Fetching remote branch 'master'."
90
- And output includes "Merging remote branch 'master' from 'config.owner/config.repo'."
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 "Retrieving branch information from gitcycle."
99
- And output includes "Creating GitHub pull request."
100
- And output does not include "Branch not found."
101
- And output does not include "Opening issue"
102
- And output includes "You must push code before opening a pull request."
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 "Retrieving branch information from gitcycle."
112
- And output includes "Creating GitHub pull request."
113
- And output does not include "Branch not found."
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
- # Scenario: QA issue
158
- # When I cd to the owner repo
159
- # And I checkout master
160
- # And I execute gitcycle with "qa issue.id"
161
- # Then gitcycle runs
162
- # And output includes
163
- # """
164
- # Retrieving branch information from gitcycle.
165
- # Deleting old QA branch 'qa_master'.
166
- # Creating QA branch 'qa_master'.
167
- # Adding remote repo 'br/gitcycle_test'.
168
- # Fetching remote branch '200-test-ticket'.
169
- # Merging remote branch '200-test-ticket' from 'br/gitcycle_test'.
170
- # Pushing QA branch 'qa_master'.
171
- # Type 'gitc qa pass' to approve all issues in this branch.
172
- # Type 'gitc qa fail' to reject all issues in this branch.
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.gsub(/\n+/, "\n").include?(expected).should == false
205
+ @output.include?(expected).should == false
206
206
  end
207
207
 
208
208
  Then /^redis entries valid$/ do
data/gitcycle.gemspec CHANGED
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "gitcycle"
9
- s.version = '0.1.8'
9
+ s.version = '0.1.9'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
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
- # unless yes?("Would you like to eventually merge this feature into #{branch['source']}?")
65
- # branch['source'] = q("What branch would you like to eventually merge this feature into?")
66
- # end
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
- # unless branches(:match => branch['source'])
69
-
70
- # end
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}'.".green
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
- $remotes ||= {}
370
+ add_remote_and_fetch(options)
371
+
372
+ puts "\nChecking out remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
349
373
 
350
- unless $remotes[owner]
351
- $remotes[owner] = true
352
- puts "Adding remote repo '#{owner}/#{repo}'.\n".green
353
- run("git remote rm #{owner}") if remotes(:match => owner)
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
- puts "\nMerging remote branch '#{branch}' from '#{owner}/#{repo}'.\n".green
361
- run("git merge #{owner}/#{branch}")
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
- $remotes ||= {}
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 8
10
- version: 0.1.8
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-19 00:00:00 -08:00
18
+ date: 2012-01-20 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency