Class: Git::CleanRemote::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/git-cleanremote/branch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/git-cleanremote/branch.rb', line 5

def name
  @name
end

#remoteObject (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

Raises:

  • (StandardError)


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

Raises:

  • (StandardError)


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_sObject



12
13
14
# File 'lib/git-cleanremote/branch.rb', line 12

def to_s
  [remote, name].join('/')
end