From: Sean Whitton Date: Wed, 17 Jul 2019 07:20:13 +0000 (+0100) Subject: git-debpush: factor out find_last_tag() X-Git-Tag: archive/debian/9.3~18 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fda8aa7b7773ee59eae0701fab7a07fc0e20263b;p=dgit.git 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 --- diff --git a/git-debpush b/git-debpush index c8295798..969ee619 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 }')