chiark / gitweb /
git-debpush: introduce and call fail_check
authorSean Whitton <spwhitton@spwhitton.name>
Wed, 17 Jul 2019 07:01:00 +0000 (08:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Jul 2019 13:12:27 +0000 (14:12 +0100)
Without this, passing --force to override an earlier sanity check
might cause the user to miss the output of a later sanity check, which
would never get run.

We don't want to have multiple forcing options to override different
sanity checks, as that is too much complexity for a script like this.

So always run all checks, and error out afterwards if at least one of
them failed.

Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
git-debpush

index 63057ed24ee3334c3cfc4dd0d5d35bcc3cdec1ef..c8295798cab4c408d5fa70be2a2ca41105aad6d9 100755 (executable)
@@ -63,6 +63,16 @@ get_file_from_ref () {
     fi
 }
 
+failed_check=false
+fail_check () {
+    if $force; then
+        echo >&2 "$us: warning: $*"
+    else
+        echo >&2 "$us: $*"
+        failed_check=true
+    fi
+}
+
 # ---- Parse command line
 
 getopt=$(getopt -s bash -o 'nfu:' \
@@ -177,22 +187,22 @@ trap - EXIT
 
 # ---- Useful sanity checks
 
-if ! $force; then
-
-    if [ "$target" = "UNRELEASED" ]; then
-        fail "UNRELEASED changelog"
-    fi
+if [ "$target" = "UNRELEASED" ]; then
+    fail_check "UNRELEASED changelog"
+fi
 
-    # TODO additional checks we might do:
-    #
-    # - are we uploading to a different suite from the last tag
-    #   (e.g. unstable after experimental)?  user should pass option to
-    #   confirm
-    #
-    # - walking backwards from $branch, if there is an archive/ strictly
-    #   before we reach most recent debian/ tag, error, this might be a
-    #   push of the dgit view to the maintainer branch
+# TODO additional checks we might do:
+#
+# - are we uploading to a different suite from the last tag
+#   (e.g. unstable after experimental)?  user should pass option to
+#   confirm
+#
+# - walking backwards from $branch, if there is an archive/ strictly
+#   before we reach most recent debian/ tag, error, this might be a
+#   push of the dgit view to the maintainer branch
 
+if ! $force && $failed_check; then
+    fail "some checks failed; you can override with --force"
 fi
 
 # ---- Create the git tag