Permalink
Browse files

Silence git fetch, track branch on gitc qa pass

  • Loading branch information...
1 parent 7619d7b commit 8e1e57e558de4389b3dacf0d927db04bfceed002 @winton committed Jan 25, 2012
Showing with 20 additions and 15 deletions.
  1. +1 −3 README.md
  2. +1 −1 features/gitcycle.feature
  3. +18 −11 lib/gitcycle.rb
View
@@ -101,6 +101,4 @@ Todo
* Instead of detecting CONFLICT, use error status $? != 0
* Add comment on lighthouse with issue URL
-* Label issues with ticket milestone?
-* Silent verbose branch output when recreating
-* gitc qa pass 1 2 3, should check if the branch exists locally
+* Label issues with ticket milestone?
@@ -81,7 +81,7 @@ Scenario: Checkout via ticket w/ fresh repo
And output includes
"""
Retrieving branch information from gitcycle.
- Tracking branch 'ticket.id'.
+ Tracking branch 'origin/ticket.id'.
"""
And current branch is "ticket.id"
View
@@ -81,13 +81,7 @@ def create_branch(url_or_title)
end
if branch['exists']
- if branches(:match => name)
- puts "Checking out branch '#{name}'.\n".green
- run("git checkout #{name}")
- else
- puts "Tracking branch '#{name}'.\n".green
- run("git fetch -q && git checkout --track -b #{name} origin/#{name}")
- end
+ checkout_or_track(:name => name, :remote => 'origin')
else
puts "Sending branch information to gitcycle.".green
get('branch',
@@ -172,10 +166,7 @@ def qa(*issues)
issues = issues[1..-1]
if pass_fail == 'pass'
- puts "Checking out #{qa_branch['source']}.".green
- run("git checkout #{qa_branch['source']}")
- run("git pull origin #{qa_branch['source']}")
- # TODO: track if source branch doesn't exist
+ checkout_or_track(:name => qa_branch['source'], :remote => 'origin')
end
if issues.empty?
@@ -369,6 +360,22 @@ def branches(options={})
end
end
+ def checkout_or_track(options={})
+ name = options[:name]
+ remote = options[:remote]
+
+ if branches(:match => name)
+ puts "Checking out branch '#{name}'.\n".green
+ run("git checkout #{name}")
+ else
+ puts "Tracking branch '#{remote}/#{name}'.\n".green
+ run("git fetch -q #{remote}")
+ run("git checkout --track -b #{name} #{remote}/#{name}")
+ end
+
+ run("git pull #{remote} #{name}")
+ end
+
def checkout_remote_branch(options={})
owner = options[:owner]
repo = options[:repo]

0 comments on commit 8e1e57e

Please sign in to comment.