chiark / gitweb /
git-debpush: Check upstream source is identical in the upstream tag
authorSean Whitton <spwhitton@spwhitton.name>
Sat, 20 Jul 2019 16:17:06 +0000 (17:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Jul 2019 22:31:26 +0000 (23:31 +0100)
Closes: #932476
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debpush
git-debpush.1.pod
tests/tests/tagupl

index dee358b2c43370a8fcca42b76abe85749f457642..1bfb0936c2e934087b50e4a2f3ec482e0af3cb37 100755 (executable)
@@ -79,6 +79,11 @@ fail_check () {
     fi
 }
 
+fail_check_upstream_nonidentical () {
+    fail_check upstream-nonidentical \
+ "the upstream source in tag $upstream_tag is not identical to the upstream source in $branch"
+}
+
 find_last_tag () {
     local prefix=$1
 
@@ -92,6 +97,23 @@ find_last_tag () {
     set -o pipefail
 }
 
+check_treesame () {
+    local first=$1
+    local second=$2
+    shift 2
+
+    set +e
+    git diff --exit-code "$first".."$second" -- . "$@"
+    git_diff_rc=$?
+    set -e
+
+    if [ $git_diff_rc -le 1 ]; then
+        return $git_diff_rc
+    else
+        fail "'git diff' exited with unexpected code $git_diff_rc"
+    fi
+}
+
 # **** Parse command line ****
 
 getopt=$(getopt -s bash -o 'nfu:' \
@@ -313,6 +335,19 @@ if ! [ "x$upstream_tag" = "x" ] \
  "upstream tag $upstream_tag is not an ancestor of $branch; probably a mistake"
 fi
 
+# ---- Upstream tag tree nonidentical
+
+case "$quilt_mode" in
+    gbp)
+        check_treesame "$upstream_tag" "$branch" ':!debian' ':!**.gitignore' \
+            || fail_check_upstream_nonidentical
+        ;;
+    unapplied)
+        check_treesame "$upstream_tag" "$branch" ':!debian' \
+            || fail_check_upstream_nonidentical
+        ;;
+esac
+
 # ---- Summary
 
 if $failed_check; then
index 429148d40181023c23d04e8099763ac6bdb6e7e9..a554fd5695cb245d5c5609fece34cb0cafc309c4 100644 (file)
@@ -200,6 +200,12 @@ Debian unstable after uploading to Debian experimental).
 Ignore the fact that the upstream tag is not an ancestor of the branch
 to be tagged (skipping this check is implied by B<--quilt=baredebian>).
 
+=item B<upstream-nonidentical>
+
+Ignore any differences between the upstream source in the upstream tag
+and the upstream source in the branch to be tagged (this check is only
+run when using B<--quilt=gbp> or B<--quilt=unapplied>).
+
 =item B<unreleased>
 
 Permit upload to a suite called UNRELEASED.
index 09ca53a8c542e36576ac74cd93f9488b7ff05373..9d3e45a1c177700e7674156d7256d46e1cd45406 100755 (executable)
@@ -23,10 +23,19 @@ git tag $upstreamtag
 
 git checkout -B master quilt-tip-2
 
+echo foo >bar
+git add bar
+git commit -m"corrupt the upstream source to test upstream-nonidentical check"
+
 t-tagupl-settings
 
 tagname=test-dummy/$v
 
+t-expect-fail "the upstream source in tag $upstreamtag is not identical to the upstream source in refs/heads/master" \
+t-tagupl-test --quilt=gbp --upstream=$upstreamtag
+
+git reset --hard HEAD~1
+
 t-expect-fail "upstream tag $upstreamtag is not an ancestor of refs/heads/master" \
 t-tagupl-test --quilt=gbp --upstream=$upstreamtag