Permalink
Browse files

Add more explanation for unresolvable git refs

* Clarify language.
* Show the command that we ran to resolve the branch/tag/whatever
* Add a hint about v1.2.3 vs. 1.2.3
* Use the ErrorReporter to show other relevant info.
  • Loading branch information...
1 parent ab5dd37 commit 6a69a3d65262312f7a6f0af0126854fcd09ce0aa @danielsdeleo danielsdeleo committed with sethvargo Mar 3, 2014
Showing with 18 additions and 2 deletions.
  1. +3 −0 lib/omnibus/exceptions.rb
  2. +15 −2 lib/omnibus/fetchers/git_fetcher.rb
@@ -189,4 +189,7 @@ def to_s
E
end
end
+
+ class UnresolvableGitReference < RuntimeError
+ end
end
@@ -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)

0 comments on commit 6a69a3d

Please sign in to comment.