Permalink
Browse files

Moving commit_all -> commit, fixing up a bit

  • Loading branch information...
1 parent 7272ad7 commit 4e67d77276333ef0cb5ebd857220a81152d4fad3 @winton committed Feb 5, 2012
Showing with 30 additions and 12 deletions.
  1. +1 −1 README.md
  2. +29 −11 lib/gitcycle.rb
View
@@ -126,7 +126,7 @@ Checkout the branch that you will eventually merge your feature into:
gitc checkout master
-Type `gitc reset` + your ticket URL to reset the branch:
+Type `gitc redo` + your ticket URL to reset the branch:
gitc redo https://xxx.lighthouseapp.com/projects/0000/tickets/0000-my-ticket
View
@@ -75,19 +75,33 @@ def checkout(remote, branch=nil)
end
alias :co :checkout
- def commit_all
- branch_info = get('branch',
- 'branch[name]' => branches(:current => true),
- 'create' => 0
- )
+ def commit(*args)
+ msg = nil
- if branch_info && (title = branch_info["title"]) && id = branch_info["body"].match(/#\d+/)
- commit_msg = "[#{id}] #{title}"
+ if args.empty?
+ puts "\nRetrieving branch information from gitcycle.\n".green
+ branch = get('branch',
+ 'branch[name]' => branches(:current => true),
+ 'create' => 0
+ )
+
+ id = branch["lighthouse_url"].match(/tickets\/(\d+)/)[1] rescue nil
+ title = branch["title"]
+
+ if branch && id
+ msg = "[#{id}]"
+ msg += " #{title}" if title
+ end
end
- run "git add . && git commit -am" + (commit_msg ? " \"#{commit_msg}\"" : "")
+ if msg
+ run("git add . -u && git commit -am #{msg.dump}")
+ Kernel.exec("git commit --amend")
+ else
+ exec_git(:commit, args)
+ end
end
- alias :ca :commit_all
+ alias :ci :commit
def create_branch(url_or_title, reset=false)
require_git && require_config
@@ -412,8 +426,7 @@ def start(args=[])
`git --help`.scan(/\s{3}(\w+)\s{3}/).flatten.each do |cmd|
if command == cmd && !self.respond_to?(command)
- args.unshift("git", command)
- Kernel.exec(*args)
+ exec_git(cmd, args)
end
end
@@ -596,6 +609,11 @@ def create_qa_branch(options)
end
end
+ def exec_git(command, args)
+ args.unshift("git", command)
+ Kernel.exec(*args)
+ end
+
def fix_conflict(options)
owner = options[:owner]
repo = options[:repo]

0 comments on commit 4e67d77

Please sign in to comment.