Skip to content

Commit

Permalink
Merge branch 'master' of github.com:winton/gitcycle
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
tongueroo committed Jan 25, 2012
2 parents 129df61 + 2fcedab commit 4cd0473
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ This will add a "pass" label to the issue and will complete the pull request by
Todo Todo
---- ----


* Check for conflict whenever merge happens
* Add conflict check when calling "qa pass [ticket]"
* Instead of detecting CONFLICT, use error status $? != 0 * Instead of detecting CONFLICT, use error status $? != 0
* Add comment on lighthouse with issue URL * Add comment on lighthouse with issue URL
* Label issues with ticket milestone? * 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 * gitc qa pass, should not set ticket to pending-approval if its already resolved
2 changes: 1 addition & 1 deletion features/gitcycle.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Scenario: Checkout via ticket w/ fresh repo
And output includes And output includes
""" """
Retrieving branch information from gitcycle. Retrieving branch information from gitcycle.
Tracking branch 'ticket.id'. Tracking branch 'origin/ticket.id'.
""" """
And current branch is "ticket.id" And current branch is "ticket.id"


Expand Down
2 changes: 1 addition & 1 deletion gitcycle.gemspec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)


Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "gitcycle" s.name = "gitcycle"
s.version = '0.1.12' s.version = '0.1.13'
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.authors = [ 'Winton Welsh' ] s.authors = [ 'Winton Welsh' ]
s.email = [ 'mail@wintoni.us' ] s.email = [ 'mail@wintoni.us' ]
Expand Down
36 changes: 23 additions & 13 deletions lib/gitcycle.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,13 +81,7 @@ def create_branch(url_or_title)
end end


if branch['exists'] if branch['exists']
if branches(:match => name) checkout_or_track(:name => name, :remote => 'origin')
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
else else
puts "Sending branch information to gitcycle.".green puts "Sending branch information to gitcycle.".green
get('branch', get('branch',
Expand Down Expand Up @@ -172,10 +166,7 @@ def qa(*issues)
issues = issues[1..-1] issues = issues[1..-1]


if pass_fail == 'pass' if pass_fail == 'pass'
puts "Checking out #{qa_branch['source']}.".green checkout_or_track(:name => qa_branch['source'], :remote => 'origin')
run("git checkout #{qa_branch['source']}")
run("git pull origin #{qa_branch['source']}")
# TODO: track if source branch doesn't exist
end end


if issues.empty? if issues.empty?
Expand Down Expand Up @@ -355,7 +346,7 @@ def add_remote_and_fetch(options={})
end end


puts "Fetching remote repo '#{owner}/#{repo}'.\n".green puts "Fetching remote repo '#{owner}/#{repo}'.\n".green
run("git fetch #{owner}") run("git fetch -q #{owner}")
end end


def branches(options={}) def branches(options={})
Expand All @@ -369,14 +360,33 @@ def branches(options={})
end end
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={}) def checkout_remote_branch(options={})
owner = options[:owner] owner = options[:owner]
repo = options[:repo] repo = options[:repo]
branch = options[:branch] branch = options[:branch]
target = options[:target] || branch target = options[:target] || branch


if branches(:match => target) 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 checkout #{target}")
run("git pull origin #{target}") run("git pull origin #{target}")
return return
Expand Down

0 comments on commit 4cd0473

Please sign in to comment.