X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=build-aux%2Fdo-release-commit-and-tag;h=4472ff50d2a8dc2ffa38453d29221b47dc5f796c;hb=dc02bf0d39a3ae0d90d9b7b0feb32c2cc7cdff86;hp=a0d1c9c1da45cd82ea29a10e73832db4acef11f8;hpb=dc84183747ce1703eb99685b5dbde1f65a143c06;p=debian%2Fgzip diff --git a/build-aux/do-release-commit-and-tag b/build-aux/do-release-commit-and-tag index a0d1c9c..4472ff5 100755 --- a/build-aux/do-release-commit-and-tag +++ b/build-aux/do-release-commit-and-tag @@ -3,11 +3,11 @@ # controlled .prev-version file, automate the procedure by which we record # the date, release-type and version string in the NEWS file. That commit # will serve to identify the release, so apply a signed tag to it as well. -VERSION=2012-06-07.15 # UTC +VERSION=2018-03-07.03 # UTC # Note: this is a bash script (could be zsh or dash) -# Copyright (C) 2009-2012 Free Software Foundation, Inc. +# Copyright (C) 2009-2018 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ VERSION=2012-06-07.15 # UTC # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # Written by Jim Meyering @@ -28,9 +28,6 @@ ME=$(basename "$0") warn() { printf '%s: %s\n' "$ME" "$*" >&2; } die() { warn "$*"; exit 1; } -noteworthy='* Noteworthy changes in release' -noteworthy_stub="$noteworthy ?.? (????-??-??) [?]" - help() { cat < +License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. EOF exit } -branch=master +## ------ ## +## Main. ## +## ------ ## + +# Constants. +noteworthy='* Noteworthy changes in release' +noteworthy_stub="$noteworthy ?.? (????-??-??) [?]" + +# Variables. +branch=$(git branch | sed -ne '/^\* /{s///;p;q;}') builddir=. while test $# != 0 @@ -88,7 +94,7 @@ do opt=$(echo "$1" | sed -e 's/=.*//') val=$(echo "$1" | sed -e 's/[^=]*=//') shift - set dummy "$opt" "$val" ${1+"$@"}; shift + set dummy "$opt" "$val" "$@"; shift ;; esac @@ -107,6 +113,11 @@ test $# = 2 \ ver=$1 type=$2 + +## ---------------------- ## +## First, sanity checks. ## +## ---------------------- ## + # Verify that $ver looks like a version number, and... echo "$ver"|grep -E '^[0-9][0-9.]*[0-9]$' > /dev/null \ || die "invalid version: $ver" @@ -124,41 +135,45 @@ case $type in *) die "invalid release type: $type";; esac +# No local modifications allowed. +case $(git diff-index --name-only HEAD) in + '') ;; + *) die 'this tree is dirty; commit your changes first';; +esac + +# Ensure the current branch name is correct: +curr_br=$(git rev-parse --symbolic-full-name HEAD) +test "$curr_br" = "refs/heads/$branch" || die not on branch $branch + # Extract package name from Makefile. Makefile=$builddir/Makefile pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' "$Makefile") \ || die "failed to determine package name from $Makefile" -# simple check: no question marks on line 3 of NEWS +# Check that line 3 of NEWS is the stub line about to be replaced. test "$(sed -n 3p NEWS)" = "$noteworthy_stub" \ - || die 'line 3 of NEWS looks fishy!' + || die "line 3 of NEWS must be exactly '$noteworthy_stub'" -# No dirt allowed. -case $(git diff-index --name-only HEAD) in - '') ;; - *) die 'this tree is dirty; commit your changes first';; -esac +## --------------- ## +## Then, changes. ## +## --------------- ## -# update NEWS to have today's date, plus desired version number and $type +# Update NEWS to have today's date, plus desired version number and $type. perl -MPOSIX -ni -e 'my $today = strftime "%F", localtime time;' \ -e 'my ($type, $ver) = qw('"$type $ver"');' \ -e 'my $pfx = "'"$noteworthy"'";' \ -e 'print $.==3 ? "$pfx $ver ($today) [$type]\n" : $_' \ NEWS || die 'failed to update NEWS' -# Ensure the current branch name is correct: -curr_br=$(git rev-parse --symbolic-full-name HEAD) -test "$curr_br" = refs/heads/$branch || die not on branch $branch - printf "version $ver\n\n* NEWS: Record release date.\n" \ | git commit -F - -a || die 'git commit failed' git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed' # Local variables: # indent-tabs-mode: nil -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "VERSION=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: " # UTC" # End: