Class: Git::CleanRemote::Branch
- Inherits:
-
Object
- Object
- Git::CleanRemote::Branch
- Defined in:
- lib/git-cleanremote/branch.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Instance Method Summary collapse
- #delete! ⇒ Object
-
#initialize(name, remote) ⇒ Branch
constructor
A new instance of Branch.
- #local_delete! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, remote) ⇒ Branch
Returns a new instance of Branch.
7 8 9 10 |
# File 'lib/git-cleanremote/branch.rb', line 7 def initialize(name, remote) @name = name @remote = remote end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/git-cleanremote/branch.rb', line 5 def name @name end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
5 6 7 |
# File 'lib/git-cleanremote/branch.rb', line 5 def remote @remote end |
Instance Method Details
#delete! ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/git-cleanremote/branch.rb', line 16 def delete! error = '' status = Open4::popen4("git push #{remote} --delete #{name}") do |pid, stdin, stdout, stderr| error = stderr.gets.to_s end raise StandardError, error if status.to_i > 0 true end |
#local_delete! ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/git-cleanremote/branch.rb', line 25 def local_delete! error = '' status = Open4::popen4("git branch -D #{name}") do |pid, stdin, stdout, stderr| error = stderr.gets.to_s end raise StandardError, error if status.to_i > 0 true end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/git-cleanremote/branch.rb', line 12 def to_s [remote, name].join('/') end |