109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/pdk/util/git.rb', line 109
def self.ls_remote(repo, ref)
if PDK::Util::Filesystem.directory?(repo)
repo = 'file://' + repo
end
output = git('ls-remote', '--refs', repo, ref)
unless output[:exit_code].zero?
PDK.logger.error output[:stdout]
PDK.logger.error output[:stderr]
raise PDK::CLI::ExitWithError, _('Unable to access the template repository "%{repository}"') % {
repository: repo,
}
end
matching_refs = output[:stdout].split(%r{\r?\n}).map { |r| r.split("\t") }
matching_ref = matching_refs.find { |_sha, remote_ref| remote_ref == "refs/tags/#{ref}" || remote_ref == "refs/remotes/origin/#{ref}" || remote_ref == "refs/heads/#{ref}" }
raise PDK::CLI::ExitWithError, _('Unable to find a branch or tag named "%{ref}" in %{repo}') % { ref: ref, repo: repo } if matching_ref.nil?
matching_ref.first
end
|