Class: EacGit::Local::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_git/local/branch.rb

Constant Summary collapse

REFS_PREFIX =
'refs/heads/'

Instance Method Summary collapse

Instance Method Details

#current_commit_idString

Deprecated.

Use #head_commit_id instead.

Returns:

  • (String)


12
13
14
# File 'lib/eac_git/local/branch.rb', line 12

def current_commit_id
  head_commit_id
end

#exist?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/eac_git/local/branch.rb', line 17

def exist?
  local.command('show-ref', '--quiet', full_ref_name).execute.fetch(:exit_code).zero?
end

#full_ref_nameObject



21
22
23
# File 'lib/eac_git/local/branch.rb', line 21

def full_ref_name
  "#{REFS_PREFIX}#{name}"
end

#head_commitEacGit::Local::Commit



26
27
28
# File 'lib/eac_git/local/branch.rb', line 26

def head_commit
  local.commit(head_commit_id, true)
end

#head_commit_idString

Returns:

  • (String)


31
32
33
# File 'lib/eac_git/local/branch.rb', line 31

def head_commit_id
  local.rev_parse(full_ref_name, true)
end

#push(remote, options = {}) ⇒ void

This method returns an undefined value.

Parameters:



37
38
39
40
41
42
# File 'lib/eac_git/local/branch.rb', line 37

def push(remote, options = {})
  options[:refspec] = name
  options.inject(remote.push) do |a, e|
    a.send(*e)
  end.perform
end