Class: Gemkeeper::RepoFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gemkeeper/repo_fetcher.rb

Overview

Resolves a gem’s source repo URL (manifest lookup, with an optional gemkeeper.yml override) and clones or pulls it, mapping git authentication failures to actionable guidance.

Constant Summary collapse

AUTH_ERROR_PATTERNS =
[
  /authentication failed/i,
  /could not read from remote repository/i,
  /permission denied \(publickey\)/i,
  /repository not found/i,
  /fatal: credential/i
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(manifest, repos_path) ⇒ RepoFetcher

Returns a new instance of RepoFetcher.



16
17
18
19
# File 'lib/gemkeeper/repo_fetcher.rb', line 16

def initialize(manifest, repos_path)
  @manifest   = manifest
  @repos_path = repos_path
end

Instance Method Details

#fetch(gem_def) ⇒ Object

Resolves the repo URL, clones/pulls it, and returns [GitRepository, local_path].



22
23
24
25
# File 'lib/gemkeeper/repo_fetcher.rb', line 22

def fetch(gem_def)
  local_path = File.join(@repos_path, gem_def.name)
  [clone_or_pull(resolve(gem_def), local_path), local_path]
end

#resolve(gem_def) ⇒ Object

Explicit repo: in gemkeeper.yml wins, but warns on divergence from the manifest. Otherwise the repo is resolved from the manifest by gem name.



29
30
31
32
33
34
35
36
37
# File 'lib/gemkeeper/repo_fetcher.rb', line 29

def resolve(gem_def)
  name = gem_def.name
  override = gem_def.repo
  manifest_repo = @manifest.repo_for(name)
  return manifest_repo || missing_repo!(name) unless override

  warn_if_divergent(name, override, manifest_repo)
  override
end