Permalink
Browse files

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

  • Loading branch information...
winton committed Jul 3, 2013
2 parents 159f090 + 678ae9a commit 66b68919c3debf0273cfa82d38156ca8ba60476b
Showing with 34 additions and 1 deletion.
  1. +14 −1 README.md
  2. +20 −0 lib/gitcycle.rb
View
@@ -76,6 +76,13 @@ When the branch is ready for code review:
This will label the pull request as "Pending Review".
+Open
+----
+
+If you want to view the pull request without updating the ticket:
+
+ gitc open
+
Code Review
-----------
@@ -142,6 +149,12 @@ Checkout a branch from a ticket URL:
gitc checkout [TICKET URL]
+### From Ticket Number
+
+Checkout a branch from a ticket #:
+
+ gitc checkout [TICKET NUMBER]
+
### From User's Fork
gitc checkout user/branch
@@ -169,4 +182,4 @@ Nice to haves:
$ gitc st - shortcut
* gitc clean # to clean up old branches
* fail should change to inactive
-* gitc pull: shouldnt matter who does it, it should update the latest br/rc, not working https://gist.github.com/22b1e248e8dba7a32288
+* gitc pull: shouldnt matter who does it, it should update the latest br/rc, not working https://gist.github.com/22b1e248e8dba7a32288
View
@@ -129,6 +129,24 @@ def checkout(*args)
puts "\nBranch not found!\n".red
puts "\nDid you mean: gitc branch #{args[0]}\n".yellow
end
+ elsif args[0] =~ /^\d*$/
+ puts "\nLooking for a branch for LH ticket ##{args[0]}.\n".green
+ results = branches(:array => true).select {|b| b.include?("-#{args[0]}-") }
+ if results.size == 0
+ puts "\nNo matches for ticket ##{args[0]} found.\n".red
+ elsif results.size == 1
+ branch = results.first
+ if branch.strip == branches(:current => true).strip
+ puts "Already on Github branch for LH ticket ##{args[0]} (#{branch})".yellow
+ else
+ puts "\nSwitching to branch '#{branch}'\n".green
+ run("git checkout #{branch}")
+ end
+ else
+ puts "\nFound #{results.size} matches with that LH ticket number:\n".yellow
+ puts results
+ puts "\nDid not switch branches. Please check your ticket number.\n".red
+ end
else
remote, branch = args[0].split('/')
remote, branch = nil, remote if branch.nil?
@@ -585,6 +603,8 @@ def branches(options={})
b.match(/\*\s+(.+)/)[1]
elsif options[:match]
b.match(/([\s]+|origin\/)(#{options[:match]})$/)[2] rescue nil
+ elsif options[:array]
+ b.split(/\n/).map{|b| b[2..-1]}
else
b
end

0 comments on commit 66b6891

Please sign in to comment.