pass release arguments to pre/post-release scripts

With some modification to catch up with latest situation.
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
This commit is contained in:
Daniel Bruder 2013-09-27 12:31:07 +02:00 committed by spacewander
parent 4917796d63
commit b41a4cf05b
2 changed files with 19 additions and 10 deletions

View file

@ -442,7 +442,7 @@ removed.
## git release
Release commit with the given &lt;tag&gt;:
Release commit with the given &lt;tag&gt; and other options:
```bash
$ git release 0.1.0
@ -450,11 +450,11 @@ $ git release 0.1.0
Does the following:
- Executes _.git/hooks/pre-release.sh_ (if present)
- Executes _.git/hooks/pre-release.sh_ (if present), passing it the given tag and remain arguments
- Commits changes (to changelog etc) with message "Release &lt;tag&gt;"
- Tags with the given &lt;tag&gt;
- Push the branch / tags
- Executes _.git/hooks/post-release.sh_ (if present)
- Executes _.git/hooks/post-release.sh_ (if present), passing it the given tag and remain arguments
## git rename-branch

View file

@ -9,10 +9,11 @@ hook() {
if test -f $hook; then
echo "... $1"
shift
if test -x $hook; then
$hook
$hook "$@"
else
. $hook
. $hook "$@"
fi
fi
}
@ -21,16 +22,16 @@ if test $# -gt 0; then
version=$1
shift #remove version from arguments list
remote=''
hook pre-release
echo "... releasing $version"
hook_args="$version"
# check for flags
while test $# != 0
do
case "$1" in
-c) git-changelog -t "$version" ;;
-c) need_changelog=true;;
-r) remote=$2; shift ;;
-m) msg=$2; shift ;;
--) shift; break;;
--) shift; hook_args="$hook_args $*"; break;;
*) usage ;;
esac
shift
@ -38,11 +39,19 @@ if test $# -gt 0; then
if [ -z "$msg" ]; then
msg="Release ${version}"
fi
# shellcheck disable=SC2086
hook pre-release $hook_args
echo "... releasing $version"
if [ "$need_changelog" = true ]; then
git-changelog -t "$version"
fi
git commit -a -m "$msg"
# shellcheck disable=SC2086
git tag $version -a -m "$msg" \
&& git push $remote \
&& git push $remote --tags \
&& hook post-release \
&& hook post-release $hook_args \
&& echo "... complete"
else
echo "tag required" 1>&2 && exit 1