Add flags -s and -u for signed tags

This commit is contained in:
Tom Andrade 2019-11-24 14:59:56 +01:00
parent a6a1754093
commit 704b1b4fdd
5 changed files with 63 additions and 4 deletions

View file

@ -34,6 +34,17 @@ if test $# -gt 0; then
-c) need_changelog=true;;
-r) remote=$2; shift ;;
-m) msg=$2; shift ;;
-s)
test -n "$keyid" &&
exit_with_msg "Please use '-s' OR '-u'"
sign=true
;;
-u)
test -n "$sign" &&
exit_with_msg "Please use '-s' OR '-u'"
keyid=$2
shift
;;
--semver)
test -z "$2" &&
exit_with_msg "major/minor/patch required for --semver option"
@ -101,8 +112,17 @@ if test $# -gt 0; then
git commit -a -m "$msg" --allow-empty
fi
declare -a sign_args
if [ "$sign" == true ]; then
sign_args=("-s")
fi
if [ -n "$keyid" ]; then
sign_args=("-u" "$keyid")
fi
# shellcheck disable=SC2086
git tag $version -a -m "$msg" \
git tag "${sign_args[@]}" $version -a -m "$msg" \
&& git push $remote --tags \
&& git push $remote \
&& hook post-release $hook_args \

View file

@ -429,6 +429,17 @@ _git-summary() {
__gitex_commits
}
_git-release() {
_arguments -C \
'-c[Generates/populates the changelog with all commit message since the last tag.]'
'-r[The "remote" repository that is destination of a push operation.]'
'-m[use the custom commit information instead of the default message.]'
'-s[Create a signed and annotated tag.]'
'-u[Create a tag, annotated and signed with the given key.]'
'--semver[If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag.]'
'--no-empty-commit[Avoid creating empty commit if nothing could be committed.]'
'--[The arguments listed after "--" separator will be passed to pre/post-release hook.]'
}
_git-undo(){
_arguments -C \

View file

@ -7,7 +7,7 @@
\fBgit\-release\fR \- Commit, tag and push changes to the repository
.
.SH "SYNOPSIS"
\fBgit\-release\fR [<tagname> | \-\-semver <name>] [\-r <remote>] [\-m <commit info>] [\-\-no\-empty\-commit] [\-c] [[\-\-] <hook arguments\.\.\.>]
\fBgit\-release\fR [<tagname> | \-\-semver <name>] [\-r <remote>] [\-m <commit info>] [\-\-no\-empty\-commit] [\-c] [\-s] [\-u <key-id>] [[\-\-] <hook arguments\.\.\.>]
.
.SH "DESCRIPTION"
Commits changes with message "Release <tagname>" or custom commit information, tags with the given <tagname> and pushes the branch / tags\.
@ -58,6 +58,18 @@ Avoid creating empty commit if nothing could be committed\.
Generates or populates the changelog with all commit message since the last tag\. For more info see git\-changelog\.\.
.
.P
\-s
.
.P
Create a signed and annotated tag\.
.
.P
\-u <key ID>
.
.P
Create a tag, annotated and signed with the given key\.
.
.P
[\-\-] hook arguments\.\.\.
.
.P

View file

@ -76,7 +76,7 @@
<h2 id="SYNOPSIS">SYNOPSIS</h2>
<p><code>git-release</code> [&lt;tagname&gt; | --semver &lt;name&gt;] [-r &lt;remote&gt;] [-m &lt;commit info&gt;] [--no-empty-commit] [-c] [[--] &lt;hook arguments...&gt;]</p>
<p><code>git-release</code> [&lt;tagname&gt; | --semver &lt;name&gt;] [-r &lt;remote&gt;] [-m &lt;commit info&gt;] [--no-empty-commit] [-c] [-s] [-u &lt;key-id&gt;] [[--] &lt;hook arguments...&gt;]</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
@ -116,6 +116,14 @@
<p> Generates or populates the changelog with all commit message since the last tag. For more info see git-changelog..</p>
<p> -s</p>
<p> Create a signed and annotated tag.</p>
<p> -u &lt;key-id&gt;</p>
<p> Create a tag, annotated and signed with the given key.</p>
<p> [--] hook arguments...</p>
<p> The arguments listed after "--" separator will be passed to pre/post-release hook following the <code>tagname</code>.</p>

View file

@ -3,7 +3,7 @@ git-release(1) -- Commit, tag and push changes to the repository
## SYNOPSIS
`git-release` [&lt;tagname&gt; | --semver &lt;name&gt;] [-r &lt;remote&gt;] [-m &lt;commit info&gt;] [--no-empty-commit] [-c] [[--] &lt;hook arguments...&gt;]
`git-release` [&lt;tagname&gt; | --semver &lt;name&gt;] [-r &lt;remote&gt;] [-m &lt;commit info&gt;] [--no-empty-commit] [-c] [-s] [-u &lt;key-id&gt;] [[--] &lt;hook arguments...&gt;]
## DESCRIPTION
@ -43,6 +43,14 @@ git-release(1) -- Commit, tag and push changes to the repository
Generates or populates the changelog with all commit message since the last tag. For more info see git-changelog..
-s
Create a signed and annotated tag.
-u &lt;key-id&gt;
Create a tag, annotated and signed with the given key.
[--] hook arguments...
The arguments listed after "--" separator will be passed to pre/post-release hook following the `tagname`.