Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing fatal git error resulting from pulling non-existent branch, re…

…-adding tracking on checkout
  • Loading branch information...
commit 3e17abfa60955fbb37eb9731750a7665139387ed 1 parent 547d30c
@winton authored
Showing with 22 additions and 17 deletions.
  1. +0 −1  README.md
  2. +11 −10 features/gitcycle.feature
  3. +11 −6 lib/gitcycle.rb
View
1  README.md
@@ -115,7 +115,6 @@ If you are working in a fork, it is easy to track upstream branches:
Todo
----
-* gitc pull before gitc ready
* Fix git fatal error (related to pull?)
* On pass or fail, send email to Github email
* Change QA branch name to qa_login_branch
View
21 features/gitcycle.feature
@@ -32,9 +32,9 @@ Scenario: Feature branch w/ custom branch name
Would you like to name your branch 'ticket.id'? (y/n)
What would you like to name your branch?
Adding remote repo 'config.owner/config.repo'.
- Fetching remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Checking out remote branch 'ticket.id-rename' from 'config.owner/config.repo/master'.
- Pulling 'origin/ticket.id-rename'.
+ Fetching remote 'origin'.
Pushing 'origin/ticket.id-rename'.
Sending branch information to gitcycle.
"""
@@ -54,9 +54,9 @@ Scenario: Feature branch
Your work will eventually merge into 'master'. Is this correct? (y/n)
Would you like to name your branch 'ticket.id'? (y/n)
Adding remote repo 'config.owner/config.repo'.
- Fetching remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Checking out remote branch 'ticket.id' from 'config.owner/config.repo/master'.
- Pulling 'origin/ticket.id'.
+ Fetching remote 'origin'.
Pushing 'origin/ticket.id'.
Sending branch information to gitcycle.
"""
@@ -75,8 +75,9 @@ Scenario: Reset feature branch
Your work will eventually merge into 'master'. Is this correct? (y/n)
Would you like to name your branch 'ticket.id'? (y/n)
Adding remote repo 'config.owner/config.repo'.
- Fetching remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Checking out remote branch 'ticket.id' from 'config.owner/config.repo/master'.
+ Fetching remote 'origin'.
Pulling 'origin/ticket.id'.
Pushing 'origin/ticket.id'.
Sending branch information to gitcycle.
@@ -118,7 +119,7 @@ Scenario: Pull changes from upstream
"""
Retrieving branch information from gitcycle.
Adding remote repo 'config.owner/config.repo'.
- Fetching remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Merging remote branch 'master' from 'config.owner/config.repo'.
"""
And git log should contain the last commit
@@ -172,7 +173,7 @@ Scenario: Ready issue w/ no parameters
"""
Retrieving branch information from gitcycle.
Adding remote repo 'config.owner/config.repo'.
- Fetching remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Merging remote branch 'master' from 'config.owner/config.repo'.
Retrieving branch information from gitcycle.
Labeling issue as 'Pending Review'.
@@ -207,12 +208,12 @@ Scenario: QA issue
Retrieving branch information from gitcycle.
Deleting old QA branch 'qa_master'.
Adding remote repo 'config.owner/config.repo'.
- Fetching remote repo 'config.owner/config.repo'.
+ Fetching remote 'config.owner'.
Checking out remote branch 'qa_master' from 'config.owner/config.repo/master'.
- Pulling 'origin/qa_master'.
+ Fetching remote 'origin'.
Pushing 'origin/qa_master'.
Adding remote repo 'config.user/config.repo'.
- Fetching remote repo 'config.user/config.repo'.
+ Fetching remote 'config.user'.
Merging remote branch 'ticket.id' from 'config.user/config.repo'.
Pushing branch 'qa_master'.
Type 'gitc qa pass' to approve all issues in this branch.
View
17 lib/gitcycle.rb
@@ -366,12 +366,12 @@ def add_remote_and_fetch(options={})
run("git remote add #{owner} git@github.com:#{owner}/#{repo}.git")
end
- puts "Fetching remote repo '#{owner}/#{repo}'.\n".green
+ puts "Fetching remote '#{owner}'.\n".green
run("git fetch -q #{owner}")
end
def branches(options={})
- b = `git branch#{" -a" if options[:all]}`
+ b = `git branch#{" -a" if options[:all]}#{" -r" if options[:remote]}`
if options[:current]
b.match(/\*\s+(.+)/)[1]
elsif options[:match]
@@ -391,7 +391,7 @@ def checkout_or_track(options={})
else
puts "Tracking branch '#{remote}/#{name}'.\n".green
run("git fetch -q #{remote}")
- run("git checkout -b #{name} #{remote}/#{name}")
+ run("git checkout --track -b #{name} #{remote}/#{name}")
end
run("git pull #{remote} #{name}")
@@ -417,10 +417,15 @@ def checkout_remote_branch(options={})
add_remote_and_fetch(options)
puts "Checking out remote branch '#{target}' from '#{owner}/#{repo}/#{branch}'.\n".green
- run("git checkout -b #{target} #{owner}/#{branch}")
+ run("git checkout --track -b #{target} #{owner}/#{branch}")
- puts "Pulling 'origin/#{target}'.\n".green
- run("git pull origin #{target}")
+ puts "Fetching remote 'origin'.\n".green
+ run("git fetch -q origin")
+
+ if branches(:remote => true, :match => "origin/#{target}")
+ puts "Pulling 'origin/#{target}'.\n".green
+ run("git pull origin #{target}")
+ end
puts "Pushing 'origin/#{target}'.\n".green
run("git push origin #{target}")
Please sign in to comment.
Something went wrong with that request. Please try again.