Failing Autoupdate doesn't kill the job anymor, just issues a warning.
[buildfarm-client.git] / run_branches
index 8ee1f9f03edb6ea91c7ecf442e874c819636ba8e..7506a52ec5a6b9762b9aad3ed1d4a5cb44934288 100755 (executable)
@@ -78,35 +78,45 @@ $branch = 'global';
 require $buildconf;
 
 # Check if auto-update is wanted and possible
-if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update})
-{
-    my $remote = $EximBuild::Conf{auto_update} // 'origin';
+eval {
+    if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update})
+    {
+       my $remote = $EximBuild::Conf{auto_update} // 'origin';
 
-    die "$0: auto-update not possible: need write permissions in @{[cwd]}\n"
-       if not -w '.';
+       die "auto-update not possible: need write permissions in @{[cwd]}\n"
+           if not -w '.';
 
-    # Get information about our remote and calculate the chance for a
-    # successfull auto-updat. Based on:
-    # http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
-    system("git fetch $remote") == 0 or die $? >> 8;
-    my ($upstream, $local, $base) = qx'git rev-parse ...@{upstream}';   die $? >> 8 if $?;
-    $base =~ s/^\^//;
+       # Get information about our remote and calculate the chance for a
+       # successfull auto-updat. Based on:
+       # http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
+       system("git fetch $remote") == 0 or die "'git fetch $remote' failed\n";
+       my ($upstream, $local, $base) = qx'git rev-parse ...@{upstream}' or die "'git rev-parse' failed\n";
 
-    if ($upstream ne $local) {
+       $base =~ s/^\^//;
+
+       if ($upstream ne $local) {
+
+           if ($base ne $local) {
+               die "the merge base is not local anymore. Refusing to `git pull`\n"
+           }
 
-       if ($base ne $local) {
-           warn "$0: the merge base is not local anymore. Refusing to `git pull`\n"
-       }
-       else {
            # if we're the merge base, the ff-only should work
-           system('git pull --ff-only') == 0 or die $? >> 8;
+           # except if there are local changes. We won't stop, if we
+           # fail to update, but we'll issue a warning
+           system("git pull --ff-only $remote") == 0 or die "git pull --ff-only\n";
 
-           say "$0: re-execute after update";
-           chdir $CALLED{cwd} or die "$0: Can't chdir to $CALLED{cwd}: $!\n";
+           say "re-execute after update";
+           chdir $CALLED{cwd} or die "Can't chdir to $CALLED{cwd}: $!\n";
            exec $CALLED{argv0}, @{$CALLED{argv}};
            die "Can't re-exec\n";
        }
     }
+};
+
+if ($@) {
+    chomp $@;
+    warn "Automatic updated failed with `$@'\n"
+       ."Continue anyway\n";
 }
 
 unless (