control: tag -1 +patch

Hello,

On Fri 19 Jul 2019 at 10:51PM +01, Ian Jackson wrote:

> For gbp and unapplied, I think it would be very sensible to check that
> the upstream files are treesame in master and upstream.  (For gbp,
> ignoring /.gitignore)
>
> I think this may be a common user error and it's very easy to
> implement.

Patch attached.

Based on series in #932459.

-- 
Sean Whitton
From 3bd6d0361874b709184f6d842c02a6719b4a18d7 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhit...@spwhitton.name>
Date: Sat, 20 Jul 2019 17:17:06 +0100
Subject: [PATCH] git-debpush: Check upstream source is identical in the
 upstream tag

Closes: #932476

Signed-off-by: Sean Whitton <spwhit...@spwhitton.name>
---
 git-debpush        | 11 +++++++++++
 git-debpush.1.pod  |  6 ++++++
 tests/tests/tagupl |  9 +++++++++
 3 files changed, 26 insertions(+)

diff --git a/git-debpush b/git-debpush
index dee358b2..1407dc63 100755
--- a/git-debpush
+++ b/git-debpush
@@ -313,6 +313,17 @@ if ! [ "x$upstream_tag" = "x" ] \
  "upstream tag $upstream_tag is not an ancestor of $branch; probably a mistake"
 fi
 
+# ---- Upstream tag tree nonidentical
+
+if ! [ "x$upstream_tag" = "x" ] \
+        && ([ "$quilt_mode" = "gbp" ] \
+            || [ "$quilt_mode" = "unapplied" ]) \
+        && git diff-tree --numstat "$upstream_tag" "$branch" \
+            | grep -qvP "[0-9]+\t[0-9]+\tdebian/"; then
+    fail_check upstream-nonidentical \
+ "the upstream source in tag $upstream_tag is not identical to the upstream source in $branch"
+fi
+
 # ---- Summary
 
 if $failed_check; then
diff --git a/git-debpush.1.pod b/git-debpush.1.pod
index 429148d4..a554fd56 100644
--- a/git-debpush.1.pod
+++ b/git-debpush.1.pod
@@ -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.
diff --git a/tests/tests/tagupl b/tests/tests/tagupl
index 9845b29b..ddda3565 100755
--- a/tests/tests/tagupl
+++ b/tests/tests/tagupl
@@ -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
 
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature

Reply via email to