Class: Git::Branch
Instance Attribute Summary collapse
-
#full
Returns the value of attribute full.
-
#name
Returns the value of attribute name.
-
#remote
Returns the value of attribute remote.
Attributes inherited from Path
Instance Method Summary collapse
- #archive(file, opts = {})
- #checkout
- #contains?(commit) ⇒ Boolean
- #create
- #current
- #delete
- #gcommit
-
#in_branch(message = 'in branch work')
g.branch('new_branch').in_branch do # create new file # do other stuff return true # auto commits and switches back end.
-
#initialize(base, name) ⇒ Branch
constructor
A new instance of Branch.
- #merge(branch = nil, message = nil)
- #stashes
- #to_a
- #to_s
- #update_ref(commit)
Methods inherited from Path
Constructor Details
#initialize(base, name) ⇒ Branch
Returns a new instance of Branch.
9 10 11 12 13 14 15 |
# File 'lib/git/branch.rb', line 9 def initialize(base, name) @full = name @base = base @gcommit = nil @stashes = nil @remote, @name = parse_name(name) end |
Instance Attribute Details
#full
Returns the value of attribute full.
7 8 9 |
# File 'lib/git/branch.rb', line 7 def full @full end |
#name
Returns the value of attribute name.
7 8 9 |
# File 'lib/git/branch.rb', line 7 def name @name end |
#remote
Returns the value of attribute remote.
7 8 9 |
# File 'lib/git/branch.rb', line 7 def remote @remote end |
Instance Method Details
#archive(file, opts = {})
31 32 33 |
# File 'lib/git/branch.rb', line 31 def archive(file, opts = {}) @base.lib.archive(@full, file, opts) end |
#checkout
26 27 28 29 |
# File 'lib/git/branch.rb', line 26 def checkout check_if_create @base.checkout(@full) end |
#contains?(commit) ⇒ Boolean
63 64 65 |
# File 'lib/git/branch.rb', line 63 def contains?(commit) !@base.lib.branch_contains(commit, self.name).empty? end |
#create
51 52 53 |
# File 'lib/git/branch.rb', line 51 def create check_if_create end |
#current
59 60 61 |
# File 'lib/git/branch.rb', line 59 def current determine_current end |
#delete
55 56 57 |
# File 'lib/git/branch.rb', line 55 def delete @base.lib.branch_delete(@name) end |
#gcommit
17 18 19 20 |
# File 'lib/git/branch.rb', line 17 def gcommit @gcommit ||= @base.gcommit(@full) @gcommit end |
#in_branch(message = 'in branch work')
g.branch('new_branch').in_branch do # create new file # do other stuff return true # auto commits and switches back end
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/git/branch.rb', line 40 def in_branch( = 'in branch work') old_current = @base.lib.branch_current checkout if yield @base.commit_all() else @base.reset_hard end @base.checkout(old_current) end |
#merge(branch = nil, message = nil)
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/git/branch.rb', line 67 def merge(branch = nil, = nil) if branch in_branch do @base.merge(branch, ) false end # merge a branch into this one else # merge this branch into the current one @base.merge(@name) end end |
#stashes
22 23 24 |
# File 'lib/git/branch.rb', line 22 def stashes @stashes ||= Git::Stashes.new(@base) end |
#to_a
84 85 86 |
# File 'lib/git/branch.rb', line 84 def to_a [@full] end |
#to_s
88 89 90 |
# File 'lib/git/branch.rb', line 88 def to_s @full end |
#update_ref(commit)
80 81 82 |
# File 'lib/git/branch.rb', line 80 def update_ref(commit) @base.lib.update_ref(@full, commit) end |