Class: Houston::Adapters::VersionControl::GitAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/adapters/houston/adapters/version_control/git_adapter.rb,
app/adapters/houston/adapters/version_control/git_adapter/repo.rb,
app/adapters/houston/adapters/version_control/git_adapter/github_repo.rb,
app/adapters/houston/adapters/version_control/git_adapter/remote_repo.rb

Defined Under Namespace

Classes: GithubRepo, RemoteRepo, Repo

Class Method Summary collapse

Class Method Details

.build(project, location) ⇒ Object



25
26
27
# File 'app/adapters/houston/adapters/version_control/git_adapter.rb', line 25

def build(project, location)
  connect location, project.version_control_temp_path
end

.connect(location, temp_path) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/adapters/houston/adapters/version_control/git_adapter.rb', line 29

def connect(location, temp_path)
  location = location.to_s
  return Houston::Adapters::VersionControl::NullRepo if location.blank?

  if local_path? location
    return Houston::Adapters::VersionControl::NullRepo unless File.exists? location

    return self::Repo.new(location)
  else
    return Houston::Adapters::VersionControl::NullRepo unless File.exists?(temp_path) || can_fetch?(location)

    return self::GithubRepo.new(temp_path, location) if /github/ === location
    return self::RemoteRepo.new(temp_path, location)
  end
end

.credentialsObject



53
54
55
56
57
58
# File 'app/adapters/houston/adapters/version_control/git_adapter.rb', line 53

def credentials
  Rugged::Credentials::SshKey.new(
    username: SSH_USERNAME,
    privatekey: SSH_PRIVATEKEY,
    publickey: SSH_PUBLICKEY)
end

.errors_with_parameters(project, location) ⇒ Object

Public API for a VersionControl::Adapter ————————————————————————- #



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/adapters/houston/adapters/version_control/git_adapter.rb', line 12

def errors_with_parameters(project, location)
  location = location.to_s
  return ERROR_BLANK if location.blank?

  if local_path? location
    return ERROR_DOES_NOT_EXIST unless File.exists? location
  else
    return ERROR_CANT_CONNECT unless can_fetch? location
  end

  {}
end

.parametersObject



45
46
47
# File 'app/adapters/houston/adapters/version_control/git_adapter.rb', line 45

def parameters
  [:git_location]
end