summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-07-17 08:20:13 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2019-07-17 14:12:27 +0100
commitfda8aa7b7773ee59eae0701fab7a07fc0e20263b (patch)
tree65c3b55e8e38012ded494aa2eeda635191aaf0b4
parentdc1baff42723c52e17b5b90fc9b433225798fc61 (diff)
git-debpush: factor out find_last_tag()
Also determine the last debian/ tag earlier, for use by sanity checks. No functional change. Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-xgit-debpush29
1 files changed, 20 insertions, 9 deletions
diff --git a/git-debpush b/git-debpush
index c829579..969ee61 100755
--- a/git-debpush
+++ b/git-debpush
@@ -73,6 +73,19 @@ fail_check () {
fi
}
+find_last_tag () {
+ local prefix=$1
+
+ set +o pipefail # perl will SIGPIPE git-log(1) here
+ git log --pretty=format:'%D' --decorate=full "$branch" \
+ | perl -wne 'use Dpkg::Version;
+ @pieces = split /, /, $_;
+ @debian_tag_vs = sort { version_compare($b, $a) }
+ map { m|tag: refs/tags/'"$prefix"'(.+)| ? $1 : () } @pieces;
+ if (@debian_tag_vs) { print "'"$prefix"'$debian_tag_vs[0]\n"; exit }'
+ set -o pipefail
+}
+
# ---- Parse command line
getopt=$(getopt -s bash -o 'nfu:' \
@@ -185,6 +198,10 @@ target=$(cd $temp; dpkg-parsechangelog -SDistribution)
rm -rf "$temp"
trap - EXIT
+# ---- Gather git history information
+
+last_debian_tag=$(find_last_tag "debian/")
+
# ---- Useful sanity checks
if [ "$target" = "UNRELEASED" ]; then
@@ -258,15 +275,9 @@ debian_tag="$distro/$git_version"
# If the user didn't supply a quilt mode, look for it in a previous
# tag made by this script
if [ "x$quilt_mode" = "x" ] && [ "$format" = "3.0 (quilt)" ]; then
- set +o pipefail # perl will SIGPIPE git-log(1) here
- tag=$(git log --pretty=format:'%D' --decorate=full "$branch" \
- | perl -wne 'use Dpkg::Version;
- @pieces = split /, /, $_;
- @debian_tag_vs = sort {version_compare($b, $a)}
- map { m|tag: refs/tags/debian/(.+)| ? $1 : () } @pieces;
- if (@debian_tag_vs) { print "debian/$debian_tag_vs[0]\n"; exit }')
- if [ "x$tag" != "x" ]; then
- quilt_mode=$(git cat-file -p $(git rev-parse "$tag") \
+ set +o pipefail # perl will SIGPIPE git-cat-file(1) here
+ if [ "x$last_debian_tag" != "x" ]; then
+ quilt_mode=$(git cat-file -p $(git rev-parse "$last_debian_tag") \
| perl -wne \
'm/^\[dgit.*--quilt=([a-z+]+).*\]$/;
if ($1) { print "$1\n"; exit }')