Method: Ra10ke::GitRepo#all_refs

Defined in:
lib/ra10ke/git_repo.rb

#all_refsArray

Returns - an array of all the refs associated with the remote repository.

Examples:

[{:sha=>"0ec707e431367bbe2752966be8ab915b6f0da754", :ref=>"refs/heads/74110ac", :type=>:branch, :subtype=>nil, :name=>"74110ac"},
  :sha=>"07bb5d2d94db222dca5860eb29c184e8970f36f4", :ref=>"refs/pull/74/head", :type=>:pull, :subtype=>:head, :name=>"74"},
  :sha=>"156ca9a8ea69e056e86355b27d944e59d1b3a1e1", :ref=>"refs/heads/master", :type=>:branch, :subtype=>nil, :name=>"master"},
  :sha=>"fcc0532bbc5a5b65f3941738339e9cc7e3d767ce", :ref=>"refs/pull/249/head", :type=>:pull, :subtype=>:head, :name=>"249"},
  :sha=>"8d54891fa5df75890ee15d53080c2a81b4960f92", :ref=>"refs/pull/267/head", :type=>:pull, :subtype=>:head, :name=>"267"}]

Parameters:

  • url (String)
    • the git string either https or ssh url

Returns:

  • (Array)
    • an array of all the refs associated with the remote repository



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ra10ke/git_repo.rb', line 84

def all_refs
  @all_refs ||= remote_refs.each_with_object([]) do |line, refs|
    sha, ref = line.split("\t")
    next refs if line.include?('redirecting')
    next refs if sha.eql?('ref: refs/heads/master')

    _, type, name, subtype = ref.chomp.split('/')
    next refs unless name

    type = :tag if type.eql?('tags')
    type = type.to_sym
    subtype = subtype.to_sym if subtype
    type = :branch if type.eql?(:heads)
    refs << { sha: sha, ref: ref.chomp, type: type, subtype: subtype, name: name }
  end
end