From de364cfac10f9e45e7d9f2b0b327abf76278fdfc Mon Sep 17 00:00:00 2001
From: spacewander
Date: Sat, 10 Feb 2018 14:02:10 +0800
Subject: [PATCH] git-release: add --no-empty-commit for empty commit hater
---
bin/git-release | 9 ++++++++-
man/git-release.1 | 13 +++++++++++--
man/git-release.html | 14 ++++++++++----
man/git-release.md | 8 +++++++-
4 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/bin/git-release b/bin/git-release
index 1af5bf5..48f629f 100755
--- a/bin/git-release
+++ b/bin/git-release
@@ -35,6 +35,7 @@ if test $# -gt 0; then
-r) remote=$2; shift ;;
-m) msg=$2; shift ;;
--semver) semver=$2; shift ;;
+ --no-empty-commit) no_empty_commit=true;;
--) shift; hook_args="$hook_args $*"; break;;
*) test -z "$version" && version=$1 ;;
esac
@@ -88,7 +89,13 @@ if test $# -gt 0; then
if [ "$need_changelog" = true ]; then
git-changelog -t "$version"
fi
- git commit -a -m "$msg" --allow-empty
+
+ if [ "$no_empty_commit" = true ]; then
+ git commit -a -m "$msg" || true
+ else
+ git commit -a -m "$msg" --allow-empty
+ fi
+
# shellcheck disable=SC2086
git tag $version -a -m "$msg" \
&& git push $remote --tags \
diff --git a/man/git-release.1 b/man/git-release.1
index 44a1fc6..5b03b4d 100644
--- a/man/git-release.1
+++ b/man/git-release.1
@@ -1,18 +1,21 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
-.TH "GIT\-RELEASE" "1" "December 2017" "" ""
+.TH "GIT\-RELEASE" "1" "February 2018" "" ""
.
.SH "NAME"
\fBgit\-release\fR \- Commit, tag and push changes to the repository
.
.SH "SYNOPSIS"
-\fBgit\-release\fR [ | \-\-semver ] [\-r ] [\-m ] [\-c] [[\-\-] ]
+\fBgit\-release\fR [ | \-\-semver ] [\-r ] [\-m ] [\-\-no\-empty\-commit] [\-c] [[\-\-] ]
.
.SH "DESCRIPTION"
Commits changes with message "Release " or custom commit information, tags with the given and pushes the branch / tags\.
.
.P
+This command always creates a release commit, which could be empty if nothing changed\. It works like \fBgit merge \-\-no\-ff\fR\. If you don\'t like the behavior, you could add \fB\-\-no\-empty\-commit\fR to skip it\.
+.
+.P
Optionally it generates a changelog (see git\-changelog) and a remote can be defined\. The order of first \-c or \-r does not matter\.
.
.P
@@ -43,6 +46,12 @@ The "remote" repository that is destination of a push operation: it is passed to
use the custom commit information instead of the default message "Release " \.
.
.P
+\-\-no\-empty\-commit
+.
+.P
+Avoid creating empty commit if nothing could be committed\.
+.
+.P
\-c
.
.P
diff --git a/man/git-release.html b/man/git-release.html
index 5998704..737b434 100644
--- a/man/git-release.html
+++ b/man/git-release.html
@@ -76,12 +76,14 @@
SYNOPSIS
-git-release [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [-c] [[--] <hook arguments...>]
+git-release [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [[--] <hook arguments...>]
DESCRIPTION
Commits changes with message "Release <tagname>" or custom commit information, tags with the given <tagname> and pushes the branch / tags.
+ This command always creates a release commit, which could be empty if nothing changed. It works like git merge --no-ff. If you don't like the behavior, you could add --no-empty-commit to skip it.
+
Optionally it generates a changelog (see git-changelog) and a remote can be defined. The order of first -c or -r does not matter.
If .git/hook/pre-release or .git/hook/post-release exist, they will be triggered with tagname and extra hook arguments before/after the release.
@@ -106,6 +108,10 @@
use the custom commit information instead of the default message "Release <tagname>" .
+ --no-empty-commit
+
+ Avoid creating empty commit if nothing could be committed.
+
-c
Generates or populates the changelog with all commit message since the last tag. For more info see git-changelog..
@@ -141,8 +147,8 @@ populate changelog, and push to specific remote.
AUTHOR
-Written by Tj Holowaychuk <tj@vision-media.ca>
-Extended by David Hartmann <dh@tsl.io>
+Written by Tj Holowaychuk <tj@vision-media.ca>
+Extended by David Hartmann <dh@tsl.io>
REPORTING BUGS
@@ -155,7 +161,7 @@ Extended by David Hartmann <