mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
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:
parent
4917796d63
commit
b41a4cf05b
|
|
@ -442,7 +442,7 @@ removed.
|
|||
|
||||
## git release
|
||||
|
||||
Release commit with the given <tag>:
|
||||
Release commit with the given <tag> 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 <tag>"
|
||||
- Tags with the given <tag>
|
||||
- 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue