11#! /bin/bash
2+ # -*- indent-with-tabs: 1 -*-
23
34version=0.10
45program=${0##*/ }
@@ -9,15 +10,15 @@ if [ "$progdir" = "$program" ]; then progdir="."; fi
910function usage() {
1011 cat << EOF
1112NAME
12- $program - given a patch name and a list of files, create a patch diff
13+ $program - given a list of changed files, create a patch diff
1314
1415SYNOPSIS
15- $program [OPTIONS] ARGS
16+ $program [OPTIONS] PATHS
1617
1718DESCRIPTION
18- Given a patch name and a list of changed file, run svn diff to create
19- a patch suitable for the patch command, named with the current date
20- and the given patch name. Place this in the local patch directory.
19+ Given a list of changed file, run svn diff to create a patch
20+ suitable for the patch command, named with the current date and
21+ the given patch name. Place this in the local patch directory.
2122
2223
2324EOF
2930 fi
3031 cat << EOF
3132
32- FILES
33-
3433AUTHOR
3534 Written by Henrik Levkowetz, <henrik@tools.ietf.org>
3635
@@ -71,8 +70,8 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)";
7170# Option parsing
7271
7372# Options
74- shortopts=c:or:hvV
75- longopts=change=,overwrite,revision=,help,verbose,version
73+ shortopts=c:n: or:hvV
74+ longopts=change=,name=, overwrite,revision=,help,verbose,version
7675
7776# Default values
7877
9190
9291while true ; do
9392 case " $1 " in
94- -c| --change) CHG=" $2 " ; shift ;; # the change made by revision ARG
95- -o| --overwrite) OVER=1;; # overwrite any existing patch file
96- -h| --help) usage; exit ;; # Show this help, then exit
97- -v| --verbose) VERBOSE=1;; # Be more talkative
93+ -c| --change) CHG=" $2 " ; shift ;; # Use the change made by revision ARG
94+ -n| --name) NAME=" $2 " ; shift ;; # Patch name
95+ -o| --overwrite) OVER=1;; # Overwrite any existing patch file
96+ -h| --help) usage; exit ;; # Show this help, then exit
97+ -v| --verbose) VERBOSE=1;; # Be more talkative
9898 -V| --version) version; exit ;; # Show program version, then exit
9999 --) shift ; break ;;
100100 * ) die " Internal error, inconsistent option specification: '$1 '" ;;
@@ -105,13 +105,30 @@ done
105105# ----------------------------------------------------------------------
106106# The program itself
107107
108+ today=$( date +%s)
109+ until=$( date -d 2020-10-01 +%s)
110+ if [ $today -lt $until ]; then
111+ echo -e " \n** Please note that the --name switch must now be used if you want to specify" \
112+ " \n a name. If a changeset is given with the -c switch, the name can be" \
113+ " \n autogenerated from the commit comment, though." \
114+ " \n"
115+ fi
116+
117+
108118if [ " $CHG " ]; then
109- 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)
110- name=" $name -c$CHG "
119+ if [ " $NAME " ]; then
120+ name=" ${NAME// _/ -} -c$CHG "
121+ else
122+ 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)
123+ name=" $name -c$CHG "
124+ fi
111125else
112- if [ $# -lt 2 ]; then die " Expected patch name and file list on the command line." ; fi
113- if [[ $1 =~ / ]]; then die " Expected a patch name, but the first argument to $program seems to be a file path: '$1 '" ; fi
114- name=$1 ; shift ;
126+ if [ " $NAME " ]; then
127+ if [ $# -lt 1 ]; then die " Expected file list on the command line." ; fi
128+ name=" ${NAME// _/ -} "
129+ else
130+ die " Please use the -n switch to provide a patch name"
131+ fi
115132fi
116133
117134patchfile=$progdir /../../patches/$( date +%Y-%m-%d) -$name .patch
0 commit comments