Module: Onair::RemoteHead

Defined in:
lib/onair/remote_head.rb

Overview

Resolves the tip of origin/. git ls-remote over SSH costs ~2s in handshakes; the GitHub API answers the same question in ~0.4s when a token is ambient. Both report the live remote ref — this is a faster transport, never a cache. The ls-remote thread always starts so a failed API attempt costs nothing extra.

Constant Summary collapse

API_HOST =
"api.github.com"

Class Method Summary collapse

Class Method Details

.resolve(git:, branch:, repo:) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/onair/remote_head.rb', line 15

def self.resolve(git:, branch:, repo:)
  ls_remote = Thread.new do
    Thread.current.report_on_exception = false
    git.remote_head(branch)
  end
  api_head(repo, branch) || ls_remote.value
end