Method: GithubClient#latest_commit

Defined in:
app/clients/github_client.rb

#latest_commit(repo) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/clients/github_client.rb', line 34

def latest_commit(repo)
  res = req(:get, "/repos/#{@username}/#{repo}/git/refs")
  return nil if res.length == 0

  res.each do |ref|
    if ref['ref'].split('/')[1] == 'heads'
      return {
          sha: ref['object']['sha'],
          branch: ref['ref'].split('refs/heads/')[-1],
      }
    end
  end

  nil
end