diff --git a/lib/omnibus/exceptions.rb b/lib/omnibus/exceptions.rb index 6a36bdecb..89b9d3b0d 100644 --- a/lib/omnibus/exceptions.rb +++ b/lib/omnibus/exceptions.rb @@ -189,4 +189,7 @@ def to_s E end end + + class UnresolvableGitReference < RuntimeError + end end diff --git a/lib/omnibus/fetchers/git_fetcher.rb b/lib/omnibus/fetchers/git_fetcher.rb index da4153d43..1fa69a422 100644 --- a/lib/omnibus/fetchers/git_fetcher.rb +++ b/lib/omnibus/fetchers/git_fetcher.rb @@ -15,6 +15,8 @@ # limitations under the License. # +require 'omnibus/exceptions' + module Omnibus # Fetcher implementation for projects in git. class GitFetcher < Fetcher @@ -156,12 +158,23 @@ def revision_from_remote_reference(ref) shell.run_command shell.error! commit_ref = process_remote_list(shell.stdout, ref) - fail 'Could not parse SHA reference' unless commit_ref + + unless commit_ref + fail UnresolvableGitReference.new("Could not resolve `#{ref}' to a SHA.") + end commit_ref + rescue UnresolvableGitReference => e # skip retries + ErrorReporter.new(e, self).explain(<<-E) +Command `#{cmd}' did not find a commit for reference `#{ref}'. +The tag or branch you're looking for doesn't exist on the remote repo. +If your project uses version tags like v1.2.3, include the 'v' in your +software's version. +E + raise rescue Exception => e if retries >= 3 ErrorReporter.new(e, self).explain("Failed to find any commits for the ref '#{ref}'") - raise + fail else # Deal with github failing all the time :( time_to_sleep = 5 * (2**retries)