Method: Metior::GitHub::Repository#id_for_ref

Defined in:
lib/metior/github/repository.rb

#id_for_ref(ref) ⇒ String (private)

Returns the unique identifier for the commit the given reference – like a branch name – is pointing to

Returns the given ref name immediately if it is a full SHA1 commit ID.

Parameters:

  • ref (String)

    A symbolic reference name

Returns:

  • (String)

    The SHA1 ID of the commit the reference is pointing to

[View source]

48
49
50
51
52
# File 'lib/metior/github/repository.rb', line 48

def id_for_ref(ref)
  return ref if ref.match(/[0-9a-f]{40}/)
  @refs[ref] = Octokit.commit(@path, ref).id unless @refs.key? ref
  @refs[ref]
end