From 879c35212b4db7b84e5ab141c897f47ba13d9306 Mon Sep 17 00:00:00 2001 From: "G.raud" Date: Thu, 27 Mar 2014 13:42:14 +0100 Subject: [PATCH] archives2git: --tag, --tagname, $TAGDEF, $TAG, $archname: new options and vars HelpM: mention $archname archives2gitrc: updated --- archives2git | 31 ++++++++++++++++++++++++++----- archives2gitrc | 5 +++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/archives2git b/archives2git index e535cb5..78e3ce5 100755 --- a/archives2git +++ b/archives2git @@ -31,12 +31,15 @@ OPTIONS --gitadd-arg --gitci-arg --gitfilter + --tag + --tagname --debug --help --version SHELL VARIABLES The following shell variables are usable if appropriate in the shell code - snippets passed as command line options: \$arch, \$archdir, \$file. + snippets passed as command line options: \$arch, \$archname, \$archdir, + \$file. ENVIRONMENT GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL @@ -53,14 +56,17 @@ HelpMessage } # default parameters -RENAME='echo "$file"' # $file $arch -FILTER='false' # $file $arch -DATE='' # $arch -TITLE='echo "$arch"' # $arch +RENAME='echo "$file"' # $file $arch $archname +FILTER='false' # $file $arch $archname +DATE='' # $arch $archname +TITLE='echo "$arch"' # $arch $archname BODY="" # message taken as is ADDARGS= CIARGS= FILTERHEAD= # line separated arguments +TAG= +TAGDEF='printf version/; printf "%s\n" "$archname" | + LC_ALL=C sed -e '\''s/^.*[-_]\([0-9][-0-9.ab]*\)$/\1/'\' # config (file, environment, command line) [ -f "$HOME"/.archives2gitrc ] && . "$HOME"/.archives2gitrc GIT_WORK_TREE=${GIT_WORK_TREE-.} @@ -86,6 +92,10 @@ do shift; CIARGS="$CIARGS $1" ;; --gitfilter) shift; FILTERHEAD=$1 ;; + --tag) + TAG=$TAGDEF ;; + --tagname) + shift; TAG=$1 ;; --debug) set -x ;; --help|-h) @@ -137,6 +147,11 @@ do aunpack -X "$TMPDIR" "$arch" fi archdir=$TMPDIR + archname=$( printf "%s\n" "$arch" | LC_ALL=C sed \ + -e 's;^\([^/]*/\)*\([^/]\{1,\}\)/\{0,1\}$;\2;' \ + -e 's;\.\([Zz]\|lzo\|bz\|gz\|bz2\|xz\|lzma\|7z\|lz\|rz\|lrz\)$;;' \ + -e 's;\.\(tar\|t[Zz]\|tzo\|tbz\|tgz\|tbz2\|txz\|t7z\|tlz\|lha\|lzh\|7z\|alz\|arj\|zip\|rar\|jar\|war\|ace\|cab\|a\|cpio\|shar\|rpm\|deb\)$;;' \ + -e 's;\.\(orig\)$;;' ) # remove (almost) everything from the repository dir cd "$GIT_WORK_TREE" for file in * .* @@ -173,6 +188,12 @@ do rm -R "$(git rev-parse --git-dir)"/refs/original/ IFS=$OLDIFS fi + if [ -n "$TAG" ] + then + tagmessage=$(eval "$TAG" | LC_ALL=C tail -n +2) + tagname=$(eval "$TAG" | LC_ALL=C head -1) + git tag ${tagmessage:+-m "$tagmessage"} "$tagname" + fi done # cleanup diff --git a/archives2gitrc b/archives2gitrc index 842c532..6b190d3 100644 --- a/archives2gitrc +++ b/archives2gitrc @@ -18,3 +18,8 @@ CIARGS="" #mv */.* .; mv */* .; rmdir */' FILTERHEAD='--tree-filter mv projectdir/.* .; mv projectdir/* .' +# create an annotated tag +TAGDEF="$TAGDEF + printf '%s (%s)\n' \"\$archname\" \"\$(eval \"\$DATE\")\"" +# tag by default +#TAG=$TAGDEF -- 2.11.4.GIT