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)


14
15
16
# File 'lib/eac_git/local/branch.rb', line 14

def current_commit_id
  head_commit_id
end

#exist?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/eac_git/local/branch.rb', line 19

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

#full_ref_nameObject



23
24
25
# File 'lib/eac_git/local/branch.rb', line 23

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

#head_commitEacGit::Local::Commit



28
29
30
# File 'lib/eac_git/local/branch.rb', line 28

def head_commit
  local.commit(head_commit_id, true)
end

#head_commit_idString

Returns:

  • (String)


33
34
35
# File 'lib/eac_git/local/branch.rb', line 33

def head_commit_id
  local.rev_parse(full_ref_name, true)
end

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

This method returns an undefined value.

Parameters:



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

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