From 3c1c09c54ad272284780edcc4e22089c2e024a90 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 26 Jun 2020 15:23:52 +0000 Subject: [PATCH] Updated the bin/mkpatch to use a --name switch, normalize the name to use '-' rather than '_', and give more feedback. - Legacy-Id: 18068 --- bin/mkpatch | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/bin/mkpatch b/bin/mkpatch index cd3dbe3af..be17326e9 100755 --- a/bin/mkpatch +++ b/bin/mkpatch @@ -1,4 +1,5 @@ #!/bin/bash +# -*- indent-with-tabs: 1 -*- version=0.10 program=${0##*/} @@ -9,15 +10,15 @@ if [ "$progdir" = "$program" ]; then progdir="."; fi function usage() { cat < @@ -71,8 +70,8 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; # Option parsing # Options -shortopts=c:or:hvV -longopts=change=,overwrite,revision=,help,verbose,version +shortopts=c:n:or:hvV +longopts=change=,name=,overwrite,revision=,help,verbose,version # Default values @@ -91,10 +90,11 @@ fi while true ; do case "$1" in - -c| --change) CHG="$2"; shift;; # the change made by revision ARG - -o| --overwrite) OVER=1;; # overwrite any existing patch file - -h| --help) usage; exit;; # Show this help, then exit - -v| --verbose) VERBOSE=1;; # Be more talkative + -c| --change) CHG="$2"; shift;; # Use the change made by revision ARG + -n| --name) NAME="$2"; shift;; # Patch name + -o| --overwrite) OVER=1;; # Overwrite any existing patch file + -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 --) shift; break;; *) die "Internal error, inconsistent option specification: '$1'";; @@ -105,13 +105,30 @@ done # ---------------------------------------------------------------------- # 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 - 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" + if [ "$NAME" ]; then + 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 - if [ $# -lt 2 ]; then die "Expected patch name and file list on the command line."; fi - if [[ $1 =~ / ]]; then die "Expected a patch name, but the first argument to $program seems to be a file path: '$1'"; fi - name=$1; shift; + if [ "$NAME" ]; then + if [ $# -lt 1 ]; then die "Expected file list on the command line."; fi + name="${NAME//_/-}" + else + die "Please use the -n switch to provide a patch name" + fi fi patchfile=$progdir/../../patches/$(date +%Y-%m-%d)-$name.patch