Browse Source

Don't error out if there are no changes to commit.

Joe Clarke 1 year ago
parent
commit
c208116095
1 changed files with 19 additions and 15 deletions
  1. 19 15
      www/export_deadman.php

+ 19 - 15
www/export_deadman.php

@@ -233,24 +233,28 @@ HEADER;
 
 exec("cd $GIT_HOME && GIT_SSH_COMMAND='ssh -i $GIT_HOME/../../.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' /usr/local/bin/git commit -m 'Update switch targets from ZTP' $YAML_FILE", $output, $result);
 if ($result != 0) {
-    if (!$is_script) {
-        echo "<p><font color=\"red\">Error committing changes to git:</p>\r\n";
-        echo "<pre>\r\n";
-    } else {
-        echo "Error committing changes to git:\n";
-    }
-    foreach ($output as $line) {
-        echo "$line";
-        if ($is_script) {
-            echo "\n";
+    if ($output[0] != "Your branch is up to date") {
+        if (!$is_script) {
+            echo "<p><font color=\"red\">Error committing changes to git:</p>\r\n";
+            echo "<pre>\r\n";
         } else {
-            echo "\r\n";
+            echo "Error committing changes to git:\n";
         }
+        foreach ($output as $line) {
+            echo "$line";
+            if ($is_script) {
+                echo "\n";
+            } else {
+                echo "\r\n";
+            }
+        }
+        if (!$is_script) {
+            echo "</pre></font>\r\n";
+        }
+        exit(1);
+    } else {
+        exit(0);
     }
-    if (!$is_script) {
-        echo "</pre></font>\r\n";
-    }
-    exit(1);
 }
 
 exec("cd $GIT_HOME && GIT_SSH_COMMAND='ssh -i $GIT_HOME/../../.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' /usr/local/bin/git push", $output, $result);