diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-11 12:21:30 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-11 12:21:30 -0800 |
commit | abcb1453e210beb6de70a69d3501cf842b38636e (patch) | |
tree | 0612905ab3ec279694d2780b43274cb332757d1a /lib/git/branch.rb | |
parent | 3cb57d82c301e9b8a16f30f468401e3007845bb7 (diff) | |
download | third_party-ruby-git-abcb1453e210beb6de70a69d3501cf842b38636e.tar.gz third_party-ruby-git-abcb1453e210beb6de70a69d3501cf842b38636e.tar.xz third_party-ruby-git-abcb1453e210beb6de70a69d3501cf842b38636e.zip |
added branch and checkout functionality
Diffstat (limited to 'lib/git/branch.rb')
-rw-r--r-- | lib/git/branch.rb | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/lib/git/branch.rb b/lib/git/branch.rb index bf4d80a..3d8337b 100644 --- a/lib/git/branch.rb +++ b/lib/git/branch.rb @@ -1,16 +1,15 @@ module Git class Branch < Path - attr_accessor :full, :remote, :name, :current + attr_accessor :full, :remote, :name @base = nil @gcommit = nil - def initialize(base, name, current = false) + def initialize(base, name) @remote = nil @full = name @base = base - @current = current parts = name.split('/') if parts[1] @@ -26,5 +25,36 @@ module Git @gcommit end + def checkout + check_if_create + @base.lib.checkout(@name) + end + + def create + check_if_create + end + + def delete + @base.lib.branch_delete(@name) + end + + def current + determine_current + end + + def to_s + @name + end + + private + + def check_if_create + @base.lib.branch_new(@name) rescue nil + end + + def determine_current + @base.lib.branch_current == @name + end + end end |