Class: V::Adapters::Git::Branch
- Inherits:
-
Object
- Object
- V::Adapters::Git::Branch
- Defined in:
- lib/v/adapters/git/branches.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#commits(path = '.') ⇒ Object
Returns commits for this branch.
- #create(*args) ⇒ Object
- #destroy(opts = {}) ⇒ Object
-
#exists? ⇒ Boolean
Returns true if this branch has a startpoint, false otherwise.
-
#head ⇒ Object
Returns head for this branch.
-
#initialize(environment, name) ⇒ Branch
constructor
A new instance of Branch.
-
#tip ⇒ Object
Returns the tip of this branch.
- #update(*args) ⇒ Object
Constructor Details
#initialize(environment, name) ⇒ Branch
Returns a new instance of Branch.
34 35 36 |
# File 'lib/v/adapters/git/branches.rb', line 34 def initialize(environment, name) @environment, @name = environment, name end |
Instance Attribute Details
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
31 32 33 |
# File 'lib/v/adapters/git/branches.rb', line 31 def name @name end |
Instance Method Details
#commits(path = '.') ⇒ Object
Returns commits for this branch.
44 45 46 |
# File 'lib/v/adapters/git/branches.rb', line 44 def commits(path = '.') @commits ||= Commits.new @environment, self, path end |
#create(*args) ⇒ Object
38 39 40 41 |
# File 'lib/v/adapters/git/branches.rb', line 38 def create(*args) @environment.branch @name, *args return self end |
#destroy(opts = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/v/adapters/git/branches.rb', line 68 def destroy(opts = {}) arguments = {} arguments[ opts[:force] ? :D : :d ] = true arguments[:r] = true if opts[:remote] @environment.branch @name, arguments return self end |
#exists? ⇒ Boolean
Returns true if this branch has a startpoint, false otherwise.
53 54 55 56 57 |
# File 'lib/v/adapters/git/branches.rb', line 53 def exists? head.commit rescue V::EUNREV return false end |
#head ⇒ Object
Returns head for this branch.
48 49 50 |
# File 'lib/v/adapters/git/branches.rb', line 48 def head @head ||= Head.new @environment, self end |
#tip ⇒ Object
Returns the tip of this branch.
60 61 62 |
# File 'lib/v/adapters/git/branches.rb', line 60 def tip head.commit end |
#update(*args) ⇒ Object
64 65 66 67 |
# File 'lib/v/adapters/git/branches.rb', line 64 def update(*args) @environment.branch @name, *args.dup << { :force => true } return self end |