# File lib/git/branch.rb, line 6 def initialize(base, name) @remote = nil @full = name @base = base @gcommit = nil @stashes = nil parts = name.split('/') if parts[1] @remote = Git::Remote.new(@base, parts[0]) @name = parts[1] else @name = parts[0] end end
# File lib/git/branch.rb, line 36 def archive(file, opts = {}) @base.lib.archive(@full, file, opts) end
# File lib/git/branch.rb, line 31 def checkout check_if_create @base.checkout(@full) end
# File lib/git/branch.rb, line 56 def create check_if_create end
# File lib/git/branch.rb, line 64 def current determine_current end
# File lib/git/branch.rb, line 60 def delete @base.lib.branch_delete(@name) end
# File lib/git/branch.rb, line 22 def gcommit @gcommit ||= @base.gcommit(@full) @gcommit end
g.branch('new_branch').in_branch do
# create new file # do other stuff return true # auto commits and switches back
end
# File lib/git/branch.rb, line 45 def in_branch (message = 'in branch work') old_current = @base.lib.branch_current checkout if yield @base.commit_all(message) else @base.reset_hard end @base.checkout(old_current) end
# File lib/git/branch.rb, line 68 def merge(branch = nil, message = nil) if branch in_branch do @base.merge(branch, message) false end # merge a branch into this one else # merge this branch into the current one @base.merge(@name) end end
# File lib/git/branch.rb, line 27 def stashes @stashes ||= Git::Stashes.new(@base) end
# File lib/git/branch.rb, line 85 def to_a [@full] end
# File lib/git/branch.rb, line 89 def to_s @full end
# File lib/git/branch.rb, line 81 def update_ref(commit) @base.lib.update_ref(@full, commit) end
# File lib/git/branch.rb, line 95 def check_if_create @base.lib.branch_new(@name) rescue nil end
# File lib/git/branch.rb, line 99 def determine_current @base.lib.branch_current == @name end