summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/scripts/svn2cl.sh')
-rw-r--r--src/core/scripts/svn2cl.sh97
1 files changed, 77 insertions, 20 deletions
diff --git a/src/core/scripts/svn2cl.sh b/src/core/scripts/svn2cl.sh
index bf89bb0..06eba0e 100644
--- a/src/core/scripts/svn2cl.sh
+++ b/src/core/scripts/svn2cl.sh
@@ -32,46 +32,84 @@
# exit on any failures
set -e
+# report unset variables
+set -u
# svn2cl version
-VERSION="0.3"
+VERSION="0.5"
# set default parameters
-STRIPPREFIX=`basename $(pwd)`
+PWD=`pwd`
+STRIPPREFIX=`basename $PWD`
LINELEN=75
GROUPBYDAY="no"
INCLUDEREV="no"
-CHANGELOG="ChangeLog"
+CHANGELOG=""
+OUTSTYLE="cl"
+SVNCMD="svn --verbose --xml log"
# do command line checking
prog=`basename $0`
-while [ -n "$1" ]
+while [ $# -gt 0 ]
do
case "$1" in
--strip-prefix)
STRIPPREFIX="$2"
- shift 2
+ shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
+ ;;
+ --strip-prefix=*)
+ STRIPPREFIX="`echo "$1" | sed 's/--strip-prefix=//'`"
+ shift
;;
--linelen)
LINELEN="$2";
- shift 2
+ shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
+ ;;
+ --linelen=*)
+ LINELEN="`echo "$1" | sed 's/--linelen=//'`"
+ shift
;;
--group-by-day)
GROUPBYDAY="yes";
shift
;;
- -r|--include-rev)
+ -i|--include-rev)
INCLUDEREV="yes";
shift
;;
- -o|--output)
+ -f|--file|-o|--output)
CHANGELOG="$2"
- shift 2
+ shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
+ ;;
+ --file=*|--output=*)
+ CHANGELOG="`echo "$1" | sed 's/--[^=]*=//'`"
+ shift
;;
--stdout)
CHANGELOG="-"
shift
;;
+ --html)
+ OUTSTYLE="html"
+ shift
+ ;;
+ -r|--revision|--targets|--username|--password|--config-dir|--limit)
+ # add these as extra options to the command (with argument)
+ arg=`echo "$2" | sed "s/'/'\"'\"'/g"`
+ SVNCMD="$SVNCMD $1 '$arg'"
+ shift 2 || { echo "$prog: option requires an argument -- $1";exit 1; }
+ ;;
+ --revision=*|--targets=*|--username=*|--password=*|--config-dir=*|--limit=*)
+ # these are single argument versions of the above
+ arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
+ SVNCMD="$SVNCMD '$arg'"
+ shift
+ ;;
+ --stop-on-copy|--no-auth-cache|--non-interactive)
+ # add these as simple options
+ SVNCMD="$SVNCMD $1"
+ shift
+ ;;
-V|--version)
echo "$prog $VERSION";
echo "Written by Arthur de Jong."
@@ -82,26 +120,37 @@ do
exit 0
;;
-h|--help)
- echo "Usage: $prog [OPTION]..."
- echo "Generate a ChangeLog from a checked out subversion repository."
+ echo "Usage: $prog [OPTION]... [PATH]..."
+ echo "Generate a ChangeLog from a subversion repository."
echo ""
- echo " --strip-prefix NAME prefix to strip from all entries, defaults"
+ echo " --strip-prefix=NAME prefix to strip from all entries, defaults"
echo " to the name of the current directory"
- echo " --linelen NUM maximum length of an output line"
+ echo " --linelen=NUM maximum length of an output line"
echo " --group-by-day group changelog entries by day"
- echo " -r, --include-rev include revision numbers"
- echo " -o, --output FILE output to FILE instead of ChangeLog"
- echo " -f, --file FILE alias for -o, --output"
+ echo " -i, --include-rev include revision numbers"
+ echo " -o, --output=FILE output to FILE instead of ChangeLog"
+ echo " -f, --file=FILE alias for -o, --output"
echo " --stdout output to stdout instead of ChangeLog"
+ echo " --html output as html instead of plain text"
echo " -h, --help display this help and exit"
echo " -V, --version output version information and exit"
+ echo ""
+ echo "PATH arguments and the following options are passed to the svn log"
+ echo "command: -r, --revision, --target --stop-on-copy, --username,"
+ echo "--password, --no-auth-cache, --non-interactive, --config-dir,"
+ echo "--limit (see \`svn help log' for more information)."
exit 0
;;
- *)
+ -*)
echo "$prog: invalid option -- $1"
echo "Try \`$prog --help' for more information."
exit 1
;;
+ *)
+ arg=`echo "$1" | sed "s/'/'\"'\"'/g"`
+ SVNCMD="$SVNCMD '$arg'"
+ shift
+ ;;
esac
done
@@ -109,11 +158,19 @@ done
prog="$0"
while [ -h "$prog" ]
do
- prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$(dirname "$prog")/,"`
+ dir=`dirname "$prog"`
+ prog=`ls -ld "$prog" | sed "s/^.*-> \(.*\)/\1/;/^[^/]/s,^,$dir/,"`
done
dir=`dirname $prog`
dir=`cd $dir && pwd`
-XSL="$dir/svn2cl.xsl"
+XSL="$dir/svn2${OUTSTYLE}.xsl"
+
+# if no filename was specified, make one up
+if [ -z "$CHANGELOG" ]
+then
+ CHANGELOG="ChangeLog"
+ [ "$OUTSTYLE" != "cl" ] && CHANGELOG="$CHANGELOG.$OUTSTYLE"
+fi
# redirect stdout to the changelog file if needed
if [ "x$CHANGELOG" != "x-" ]
@@ -122,7 +179,7 @@ then
fi
# actually run the command we need
-svn --verbose --xml log | \
+eval "$SVNCMD" | \
xsltproc --stringparam strip-prefix "$STRIPPREFIX" \
--stringparam linelen $LINELEN \
--stringparam groupbyday $GROUPBYDAY \