From abcb1453e210beb6de70a69d3501cf842b38636e Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Sun, 11 Nov 2007 12:21:30 -0800 Subject: added branch and checkout functionality --- lib/git/lib.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/git/lib.rb') diff --git a/lib/git/lib.rb b/lib/git/lib.rb index bc40e0c..41b3efb 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -93,6 +93,11 @@ module Git arr end + def branch_current + branches_all.select { |b| b[1] }.first[0] rescue nil + end + + # returns hash # [tree-ish] = [[line_no, match], [line_no, match2]] # [tree-ish] = [[line_no, match], [line_no, match2]] @@ -235,6 +240,22 @@ module Git command('reset', arr_opts) end + + def branch_new(branch) + command('branch', branch) + end + + def branch_delete(branch) + command('branch', ['-d', branch]) + end + + def checkout(branch, opts = {}) + arr_opts = [] + arr_opts << '-f' if opts[:force] + arr_opts << branch.to_s + + command('checkout', arr_opts) + end private -- cgit