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 Feb 2, 2012
2 parents 400d8e5 + bb86a73 commit a00d2a1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
18 changes: 11 additions & 7 deletions README.md
Expand Up @@ -94,6 +94,12 @@ This will add a "pass" label to the issue and will complete the pull request by
More
----

### Checkout Upstream Branch

If you are working in a fork, it is easy to checkout upstream branches:

gitc checkout [BRANCH] [...]

### Reset Branch

If you associate the wrong branch with a ticket, use `gitc reset` to fix it.
Expand All @@ -106,15 +112,12 @@ Type `gitc reset` + your ticket URL to reset the branch:

gitc reset https://xxx.lighthouseapp.com/projects/0000/tickets/0000-my-ticket

### Track Upstream Branch

If you are working in a fork, it is easy to track upstream branches:

gitc track [BRANCH] [...]

Todo
----

* Add ability to associate multiple branches/pull requests with one Lighthouse ticket
* Add comment on lighthouse with issue URL
* gitc discuss should tag issue with 'Discuss'
* On pass or fail, send email to Github email
* Note you can use gitc with a string
* gitc qa pass, should not set ticket to pending-approval if its already resolved
Expand All @@ -126,4 +129,5 @@ Todo
* gitc -h or gitc help
* gitc discuss should tag issue with 'Discuss'
* gitc qa pass # since we're changing this to pass all the tickets, we need to loop through all the merged issues and update the lighthouse state to pending-qa
* gitc pull doesnt work in rc: https://gist.github.com/7e508977fbb762d186a6
* gitc pull doesnt work in rc: https://gist.github.com/7e508977fbb762d186a6
* Tag issue with milestone
8 changes: 4 additions & 4 deletions features/gitcycle.feature
Expand Up @@ -206,16 +206,16 @@ Scenario: QA issue
And output includes
"""
Retrieving branch information from gitcycle.
Deleting old QA branch 'qa_master'.
Deleting old QA branch 'qa_config.user_master'.
Adding remote repo 'config.owner/config.repo'.
Fetching remote 'config.owner'.
Checking out remote branch 'qa_master' from 'config.owner/config.repo/master'.
Checking out remote branch 'qa_config.user_master' from 'config.owner/config.repo/master'.
Fetching remote 'origin'.
Pushing 'origin/qa_master'.
Pushing 'origin/qa_config.user_master'.
Adding remote repo 'config.user/config.repo'.
Fetching remote 'config.user'.
Merging remote branch 'ticket.id' from 'config.user/config.repo'.
Pushing branch 'qa_master'.
Pushing branch 'qa_config.user_master'.
Type 'gitc qa pass' to approve all issues in this branch.
Type 'gitc qa fail' to reject all issues in this branch.
"""
Expand Down
2 changes: 1 addition & 1 deletion gitcycle.gemspec
Expand Up @@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)

Gem::Specification.new do |s|
s.name = "gitcycle"
s.version = '0.1.20'
s.version = '0.1.21'
s.platform = Gem::Platform::RUBY
s.authors = [ 'Winton Welsh' ]
s.email = [ 'mail@wintoni.us' ]
Expand Down
75 changes: 45 additions & 30 deletions lib/gitcycle.rb
Expand Up @@ -37,6 +37,24 @@ def initialize(args=nil)
start(args) if args
end

def checkout(branch)
require_git && require_config

puts "\nRetrieving repo information from gitcycle.\n".green
repo = get('repo')

add_remote_and_fetch(:owner => repo['owner'], :repo => repo['name'])

unless branches(:match => branch)
puts "Creating branch '#{branch}' from '#{repo['owner']}/#{branch}'.\n".green
run("git branch --no-track #{branch} #{repo['owner']}/#{branch}")
end

puts "Checking out '#{branch}'.\n".green
run("git checkout #{branch}")
end
alias :co :checkout

def create_branch(url_or_title, reset=false)
require_git && require_config

Expand All @@ -59,28 +77,37 @@ def create_branch(url_or_title, reset=false)

puts "\nRetrieving branch information from gitcycle.\n".green
branch = get('branch', params)

name = branch['name']
owner, repo = branch['repo'].split(':')

unless branch['exists']
branch['home'] = @git_login
branch['source'] = branches(:current => true)
begin
owner, repo = branch['repo'].split(':')

unless yes?("\nYour work will eventually merge into '#{branch['source']}'. Is this correct?")
branch['source'] = q("What branch would you like to eventually merge into?")
end
unless branch['exists']
branch['home'] = @git_login
branch['source'] = branches(:current => true)

unless yes?("Would you like to name your branch '#{name}'?")
name = q("\nWhat would you like to name your branch?")
name = name.gsub(/[\s\W]/, '-')
end
unless yes?("\nYour work will eventually merge into '#{branch['source']}'. Is this correct?")
branch['source'] = q("What branch would you like to eventually merge into?")
end

unless yes?("Would you like to name your branch '#{name}'?")
name = q("\nWhat would you like to name your branch?")
name = name.gsub(/[\s\W]/, '-')
end

checkout_remote_branch(
:owner => owner,
:repo => repo,
:branch => branch['source'],
:target => name
checkout_remote_branch(
:owner => owner,
:repo => repo,
:branch => branch['source'],
:target => name
)
end
rescue SystemExit, Interrupt
puts "\nDeleting branch from gitcycle.\n".green
branch = get('branch',
'branch[name]' => branch['name'],
'create' => 0,
'reset' => 1
)
end

Expand Down Expand Up @@ -343,18 +370,6 @@ def start(args=[])
end
end

def track(*branches)
puts "\nRetrieving repo information from gitcycle.\n".green
repo = get('repo')

branches.each do |branch|
add_remote_and_fetch(:owner => repo['owner'], :repo => repo['name'])

puts "Creating branch '#{branch}' from '#{repo['owner']}/#{branch}'.\n".green
run("git branch --no-track #{branch} #{repo['owner']}/#{branch}")
end
end

private

def add_remote_and_fetch(options={})
Expand All @@ -369,7 +384,7 @@ def add_remote_and_fetch(options={})
run("git remote rm #{owner}") if remotes(:match => owner)
run("git remote add #{owner} git@github.com:#{owner}/#{repo}.git")
end

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

0 comments on commit a00d2a1

Please sign in to comment.