From 87bdd66fa281d2d263b5d784166abb702693d2f0 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Thu, 13 Feb 2014 18:02:03 -0500 Subject: [PATCH] git: Fallback to git-clone for all snapshot failures. Not just the minor failures. --- modules/ksb/BuildException.pm | 6 ++++++ modules/ksb/Updater/Git.pm | 5 ++++- modules/ksb/Util.pm | 18 ++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/modules/ksb/BuildException.pm b/modules/ksb/BuildException.pm index e6e0a74..acb59cc 100644 --- a/modules/ksb/BuildException.pm +++ b/modules/ksb/BuildException.pm @@ -27,4 +27,10 @@ sub to_string return $exception->{exception_type} . " Error: " . $exception->{message}; } +sub message +{ + my $self = shift; + return $self->{message}; +} + 1; diff --git a/modules/ksb/Updater/Git.pm b/modules/ksb/Updater/Git.pm index b9a4ace..a198fd5 100644 --- a/modules/ksb/Updater/Git.pm +++ b/modules/ksb/Updater/Git.pm @@ -91,7 +91,10 @@ sub clone note ("\tCloning g[$module]"); - if (!$self->installGitSnapshot()) { + my $result = eval { $self->installGitSnapshot() }; + + if (my $e = had_an_exception() || !$result) { + warning($e->message()) if $e; if (0 != log_command($module, 'git-clone', ['git', 'clone', @args])) { croak_runtime("Failed to make initial clone of $module"); } diff --git a/modules/ksb/Util.pm b/modules/ksb/Util.pm index 45b7b99..9c21701 100644 --- a/modules/ksb/Util.pm +++ b/modules/ksb/Util.pm @@ -22,8 +22,9 @@ use ksb::Version qw(scriptVersion); use ksb::BuildException; use Exporter qw(import); # Use Exporter's import method -our @EXPORT = qw(list_has make_exception assert_isa assert_in any - croak_runtime croak_internal download_file absPathToExecutable +our @EXPORT = qw(list_has assert_isa assert_in any + croak_runtime croak_internal had_an_exception make_exception + download_file absPathToExecutable fileDigestMD5 log_command disable_locale_message_translation split_quoted_on_whitespace safe_unlink safe_system p_chdir pretend_open safe_rmtree get_list_digest @@ -88,6 +89,19 @@ sub make_exception return ksb::BuildException->new($exception_type, $message); } +# Helper function to return $@ if $@ is a ksb::BuildException. +# +# This function assumes that an eval block had just been used in order to set or +# clear $@ as appropriate. +sub had_an_exception +{ + if ($@ && ref $@ && $@->isa('ksb::BuildException')) { + return $@; + } + + return; +} + # Should be used for "runtime errors" (i.e. unrecoverable runtime problems that # don't indicate a bug in the program itself). sub croak_runtime