Updated the bin/mkpatch to use a --name switch, normalize the name to use '-' rather than '_', and give more feedback.

- Legacy-Id: 18068
This commit is contained in:
Henrik Levkowetz 2020-06-26 15:23:52 +00:00
parent 3a76e4a935
commit 3c1c09c54a

View file

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# -*- indent-with-tabs: 1 -*-
version=0.10 version=0.10
program=${0##*/} program=${0##*/}
@ -9,15 +10,15 @@ if [ "$progdir" = "$program" ]; then progdir="."; fi
function usage() { function usage() {
cat <<EOF cat <<EOF
NAME NAME
$program - given a patch name and a list of files, create a patch diff $program - given a list of changed files, create a patch diff
SYNOPSIS SYNOPSIS
$program [OPTIONS] ARGS $program [OPTIONS] PATHS
DESCRIPTION DESCRIPTION
Given a patch name and a list of changed file, run svn diff to create Given a list of changed file, run svn diff to create a patch
a patch suitable for the patch command, named with the current date suitable for the patch command, named with the current date and
and the given patch name. Place this in the local patch directory. the given patch name. Place this in the local patch directory.
EOF EOF
@ -29,8 +30,6 @@ EOF
fi fi
cat <<EOF cat <<EOF
FILES
AUTHOR AUTHOR
Written by Henrik Levkowetz, <henrik@tools.ietf.org> Written by Henrik Levkowetz, <henrik@tools.ietf.org>
@ -71,8 +70,8 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)";
# Option parsing # Option parsing
# Options # Options
shortopts=c:or:hvV shortopts=c:n:or:hvV
longopts=change=,overwrite,revision=,help,verbose,version longopts=change=,name=,overwrite,revision=,help,verbose,version
# Default values # Default values
@ -91,10 +90,11 @@ fi
while true ; do while true ; do
case "$1" in case "$1" in
-c| --change) CHG="$2"; shift;; # the change made by revision ARG -c| --change) CHG="$2"; shift;; # Use the change made by revision ARG
-o| --overwrite) OVER=1;; # overwrite any existing patch file -n| --name) NAME="$2"; shift;; # Patch name
-h| --help) usage; exit;; # Show this help, then exit -o| --overwrite) OVER=1;; # Overwrite any existing patch file
-v| --verbose) VERBOSE=1;; # Be more talkative -h| --help) usage; exit;; # Show this help, then exit
-v| --verbose) VERBOSE=1;; # Be more talkative
-V| --version) version; exit;; # Show program version, then exit -V| --version) version; exit;; # Show program version, then exit
--) shift; break;; --) shift; break;;
*) die "Internal error, inconsistent option specification: '$1'";; *) die "Internal error, inconsistent option specification: '$1'";;
@ -105,13 +105,30 @@ done
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# The program itself # The program itself
today=$(date +%s)
until=$(date -d 2020-10-01 +%s)
if [ $today -lt $until ]; then
echo -e "\n** Please note that the --name switch must now be used if you want to specify"\
"\n a name. If a changeset is given with the -c switch, the name can be"\
"\n autogenerated from the commit comment, though."\
"\n"
fi
if [ "$CHG" ]; then if [ "$CHG" ]; then
name=$(echo $(svn log -c $CHG | sed -r -e '/^---/d' -e '/^r[0-9]+/d' -e '/^$/d' -e 's/Merged in \[[0-9]+\] from [^:]+..//' ) | sed -r -e 's/(.*)/\L\1/' -e 's/[^[:alnum:]]/-/g' -e 's/-+/-/g' -e's/-$//' | cut -c 1-40) if [ "$NAME" ]; then
name="$name-c$CHG" name="${NAME//_/-}-c$CHG"
else
name=$(echo $(svn log -c $CHG | sed -r -e '/^---/d' -e '/^r[0-9]+/d' -e '/^$/d' -e 's/Merged in \[[0-9]+\] from [^:]+..//' ) | sed -r -e 's/(.*)/\L\1/' -e 's/[^[:alnum:]]/-/g' -e 's/-+/-/g' -e's/-$//' | cut -c 1-40)
name="$name-c$CHG"
fi
else else
if [ $# -lt 2 ]; then die "Expected patch name and file list on the command line."; fi if [ "$NAME" ]; then
if [[ $1 =~ / ]]; then die "Expected a patch name, but the first argument to $program seems to be a file path: '$1'"; fi if [ $# -lt 1 ]; then die "Expected file list on the command line."; fi
name=$1; shift; name="${NAME//_/-}"
else
die "Please use the -n switch to provide a patch name"
fi
fi fi
patchfile=$progdir/../../patches/$(date +%Y-%m-%d)-$name.patch patchfile=$progdir/../../patches/$(date +%Y-%m-%d)-$name.patch