chiark / gitweb /
git-debpush: check for pushing the dgit view to the maintainer view
authorSean Whitton <spwhitton@spwhitton.name>
Wed, 17 Jul 2019 07:42:43 +0000 (08:42 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 17 Jul 2019 13:12:27 +0000 (14:12 +0100)
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
git-debpush

index 969ee619f49f69372f4a11ad70f4cd275b5e26ac..6c41908633f10c3fca193e07ea872eacce515d89 100755 (executable)
@@ -201,6 +201,7 @@ trap - EXIT
 # ---- Gather git history information
 
 last_debian_tag=$(find_last_tag "debian/")
+last_archive_tag=$(find_last_tag "archive/debian/")
 
 # ---- Useful sanity checks
 
@@ -208,15 +209,22 @@ if [ "$target" = "UNRELEASED" ]; then
     fail_check "UNRELEASED changelog"
 fi
 
+if ! [ "x$last_debian_tag" = "x" ] && ! [ "x$last_archive_tag" = "x" ]; then
+    last_debian_tag_c=$(git rev-parse "$last_debian_tag"^{})
+    last_archive_tag_c=$(git rev-parse "$last_archive_tag"^{})
+    if ! [ "$last_debian_tag_c" = "$last_archive_tag_c" ] \
+            && git merge-base --is-ancestor \
+                   "$last_debian_tag" "$last_archive_tag"; then
+        fail_check \
+"looks like you might be trying to push the dgit view to the maintainer branch?"
+    fi
+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
 
 if ! $force && $failed_check; then
     fail "some checks failed; you can override with --force"