Skip to content
Browse files

Merge branch 'master' of github.com:winton/gitcycle

Conflicts:
	README.md
  • Loading branch information...
2 parents 129df61 + 2fcedab commit 4cd047310a0ba8fa149dd02782fc2ceabba70b6a @tongueroo tongueroo committed Jan 25, 2012
Showing with 25 additions and 19 deletions.
  1. +0 −4 README.md
  2. +1 −1 features/gitcycle.feature
  3. +1 −1 gitcycle.gemspec
  4. +23 −13 lib/gitcycle.rb
View
4 README.md
@@ -99,11 +99,7 @@ This will add a "pass" label to the issue and will complete the pull request by
Todo
----
-* Check for conflict whenever merge happens
-* Add conflict check when calling "qa pass [ticket]"
* 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
* gitc qa pass, should not set ticket to pending-approval if its already resolved
View
2 features/gitcycle.feature
@@ -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
2 gitcycle.gemspec
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
Gem::Specification.new do |s|
s.name = "gitcycle"
- s.version = '0.1.12'
+ s.version = '0.1.13'
s.platform = Gem::Platform::RUBY
s.authors = [ 'Winton Welsh' ]
s.email = [ 'mail@wintoni.us' ]
View
36 lib/gitcycle.rb
@@ -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 && 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?
@@ -355,7 +346,7 @@ def add_remote_and_fetch(options={})
end
puts "Fetching remote repo '#{owner}/#{repo}'.\n".green
- run("git fetch #{owner}")
+ run("git fetch -q #{owner}")
end
def branches(options={})
@@ -369,14 +360,33 @@ 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]
branch = options[:branch]
target = options[:target] || branch
if branches(:match => target)
- unless yes?("You already have a branch called '#{target}'. Overwrite?")
+ if yes?("You already have a branch called '#{target}'. Overwrite?")
+ run("git push origin :#{target}")
+ run("branch -D #{target}")
+ else
run("git checkout #{target}")
run("git pull origin #{target}")
return

0 comments on commit 4cd0473

Please sign in to comment.
Something went wrong with that request. Please try again.