Remove the debug die at startup. :(
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 5 Nov 2016 22:37:33 +0000 (23:37 +0100)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 5 Nov 2016 22:37:33 +0000 (23:37 +0100)
run_branches

index 9e267af44a47318ef6d1a9f263c9e302e6c78e1a..20f37902519f25f30d7c802923668fde3162b750 100755 (executable)
@@ -72,6 +72,25 @@ $branch = 'global';
 #
 require $buildconf;
 
+# Check if auto-update is wanted and possible
+if (not exists $EximBuild::Conf{auto_update} or $EximBuild::Conf{auto_update})
+{
+    die "$0: auto-update not possible: need write permissions in @{[cwd]}\n"
+       if not -w '.';
+    # http://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
+    system('git remote update') == 0 or die $? >> 8;
+    my ($upstream, $local, $base) = qx'git rev-parse ...@{upstream}';   die $? >> 8 if $?;
+    $base =~ s/^\^//;
+
+    if ($upstream ne $local) {
+       die "$0: the merge base is not local anymore. Refusing to `git pull`\n"
+           if $base ne $local;
+
+       # if we're the merge base, the ff-only should workkkkkk
+       system 'git pull --ff-only'
+    }
+}
+
 unless (
     (
         ref $EximBuild::conf{branches_to_build} eq 'ARRAY'