Class: Dapp::Dimg::GitRepo::Remote
- Inherits:
-
Base
- Object
- Base
- Dapp::Dimg::GitRepo::Remote
show all
- Defined in:
- lib/dapp/dimg/git_repo/remote.rb
Instance Attribute Summary
Attributes inherited from Base
#dimg, #name
Instance Method Summary
collapse
Methods inherited from Base
#branch, #commit_at, #commit_exists?, #diff, #exclude_paths, #find_commit_id_by_message, #lookup_object, #patches, #walker
Constructor Details
#initialize(dimg, name, url:) ⇒ Remote
Returns a new instance of Remote.
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/dapp/dimg/git_repo/remote.rb', line 5
def initialize(dimg, name, url:)
super(dimg, name)
@url = url
dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
begin
Rugged::Repository.clone_at(url, path, bare: true)
rescue Rugged::NetworkError, Rugged::SslError => e
raise Error::Rugged, code: :rugged_remote_error, data: { message: e.message, url: url }
end
end unless File.directory?(path)
end
|
Instance Method Details
#fetch!(branch = nil) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/dapp/dimg/git_repo/remote.rb', line 23
def fetch!(branch = nil)
branch ||= self.branch
dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
git.fetch('origin', [branch])
end unless dimg.ignore_git_fetch || dimg.dapp.dry_run?
end
|
#latest_commit(branch) ⇒ Object
30
31
32
|
# File 'lib/dapp/dimg/git_repo/remote.rb', line 30
def latest_commit(branch)
git.ref("refs/remotes/origin/#{branch}").target_id
end
|
#lookup_commit(commit) ⇒ Object
34
35
36
37
38
|
# File 'lib/dapp/dimg/git_repo/remote.rb', line 34
def lookup_commit(commit)
super
rescue Rugged::OdbError => _e
raise Error::Rugged, code: :commit_not_found_in_remote_git_repository, data: { commit: commit, url: url }
end
|
#path ⇒ Object
19
20
21
|
# File 'lib/dapp/dimg/git_repo/remote.rb', line 19
def path
dimg.build_path("#{name}.git").to_s
end
|