Class: Git::Branch
Instance Attribute Summary collapse
-
#full ⇒ Object
Returns the value of attribute full.
-
#name ⇒ Object
Returns the value of attribute name.
-
#remote ⇒ Object
Returns the value of attribute remote.
Attributes inherited from Path
Instance Method Summary collapse
- #archive(file, opts = {}) ⇒ Object
- #checkout ⇒ Object
- #create ⇒ Object
- #current ⇒ Object
- #delete ⇒ Object
- #gcommit ⇒ Object
-
#in_branch(message = 'in branch work') ⇒ Object
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) ⇒ Object
- #stashes ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
- #update_ref(commit) ⇒ Object
Methods inherited from Path
Constructor Details
#initialize(base, name) ⇒ Branch
Returns a new instance of Branch.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/git/branch.rb', line 10 def initialize(base, name) @remote = nil @full = name @base = base parts = name.split('/') if parts[1] @remote = Git::Remote.new(@base, parts[0]) @name = parts[1] else @name = parts[0] end end |
Instance Attribute Details
#full ⇒ Object
Returns the value of attribute full.
4 5 6 |
# File 'lib/git/branch.rb', line 4 def full @full end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/git/branch.rb', line 4 def name @name end |
#remote ⇒ Object
Returns the value of attribute remote.
4 5 6 |
# File 'lib/git/branch.rb', line 4 def remote @remote end |
Instance Method Details
#archive(file, opts = {}) ⇒ Object
38 39 40 |
# File 'lib/git/branch.rb', line 38 def archive(file, opts = {}) @base.lib.archive(@full, file, opts) end |
#checkout ⇒ Object
33 34 35 36 |
# File 'lib/git/branch.rb', line 33 def checkout check_if_create @base.checkout(@full) end |
#create ⇒ Object
58 59 60 |
# File 'lib/git/branch.rb', line 58 def create check_if_create end |
#current ⇒ Object
66 67 68 |
# File 'lib/git/branch.rb', line 66 def current determine_current end |
#delete ⇒ Object
62 63 64 |
# File 'lib/git/branch.rb', line 62 def delete @base.lib.branch_delete(@name) end |
#gcommit ⇒ Object
24 25 26 27 |
# File 'lib/git/branch.rb', line 24 def gcommit @gcommit = @base.gcommit(@full) if !@gcommit @gcommit end |
#in_branch(message = 'in branch work') ⇒ Object
g.branch(‘new_branch’).in_branch do
# create new file
# do other stuff
return true # auto commits and switches back
end
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/git/branch.rb', line 47 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) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/git/branch.rb', line 70 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 ⇒ Object
29 30 31 |
# File 'lib/git/branch.rb', line 29 def stashes @stashes ||= Git::Stashes.new(@base) end |
#to_a ⇒ Object
87 88 89 |
# File 'lib/git/branch.rb', line 87 def to_a [@full] end |
#to_s ⇒ Object
91 92 93 |
# File 'lib/git/branch.rb', line 91 def to_s @full end |
#update_ref(commit) ⇒ Object
83 84 85 |
# File 'lib/git/branch.rb', line 83 def update_ref(commit) @base.lib.update_ref(@full, commit) end |