Implemented a dry-run mode (with the "-n" command-line option)

This commit is contained in:
Pierre Pronchery 2014-12-02 21:46:24 +01:00
parent dca096c37e
commit 167079defd

View File

@ -19,6 +19,7 @@
#environment #environment
DEBUG= DEBUG=
DEVNULL="/dev/null" DEVNULL="/dev/null"
DRYRUN=0
FREECODE="https://freecode.com/users/$USERNAME" FREECODE="https://freecode.com/users/$USERNAME"
GIT_BRANCH="master" GIT_BRANCH="master"
HOMEPAGE="https://www.defora.org" HOMEPAGE="https://www.defora.org"
@ -195,15 +196,16 @@ _release_tag()
{ {
tag="$1" tag="$1"
if [ -d "CVS" ]; then if [ $DRYRUN -ne 0 ]; then
return 0
elif [ -d "CVS" ]; then
_release_tag_cvs "$tag" _release_tag_cvs "$tag"
return $? return $?
elif [ -d ".git" ]; then elif [ -d ".git" ]; then
_release_tag_git "$tag" _release_tag_git "$tag"
return $? return $?
else
return 2
fi fi
return 2
} }
_release_tag_cvs() _release_tag_cvs()
@ -249,8 +251,9 @@ _info()
#usage #usage
_usage() _usage()
{ {
echo "Usage: $PROGNAME [-Dv][-O name=value...] version" 1>&2 echo "Usage: $PROGNAME [-Dnv][-O name=value...] version" 1>&2
echo " -D Run in debugging mode" 1>&2 echo " -D Run in debugging mode" 1>&2
echo " -n Do not actually publish changes (dry-run)" 1>&2
echo " -v Verbose mode" 1>&2 echo " -v Verbose mode" 1>&2
return 1 return 1
} }
@ -258,7 +261,7 @@ _usage()
#main #main
#parse options #parse options
while getopts "DvO:" name; do while getopts "DnvO:" name; do
case "$name" in case "$name" in
D) D)
DEBUG="_debug" DEBUG="_debug"
@ -266,6 +269,9 @@ while getopts "DvO:" name; do
O) O)
export "${OPTARG%%=*}"="${OPTARG#*=}" export "${OPTARG%%=*}"="${OPTARG#*=}"
;; ;;
n)
DRYRUN=1
;;
v) v)
VERBOSE=1 VERBOSE=1
;; ;;