mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Merge pull request #944 from SimonTate/feature/sem-ver-prefix
git-release: Add prefix to semver
This commit is contained in:
commit
716459f79d
|
|
@ -51,6 +51,12 @@ if test $# -gt 0; then
|
|||
semver=$2
|
||||
shift
|
||||
;;
|
||||
--prefix)
|
||||
test -z "$2" &&
|
||||
exit_with_msg "prefix string required for --prefix option"
|
||||
prefix="$2"
|
||||
shift
|
||||
;;
|
||||
--no-empty-commit) no_empty_commit=true;;
|
||||
--) shift; hook_args="$hook_args $*"; break;;
|
||||
*) test -z "$version" && version=$1 ;;
|
||||
|
|
@ -69,7 +75,7 @@ if test $# -gt 0; then
|
|||
latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||
|
||||
if [[ ! "$latest_tag" =~ \
|
||||
^([^0-9]*)([1-9][0-9]+|[0-9])\.([1-9][0-9]+|[0-9])\.([1-9][0-9]+|[0-9])(.*) ]]; then
|
||||
^$prefix([^0-9]*)([1-9][0-9]+|[0-9])\.([1-9][0-9]+|[0-9])\.([1-9][0-9]+|[0-9])(.*) ]]; then
|
||||
echo "the latest tag doesn't match semver format requirement" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -86,9 +92,9 @@ if test $# -gt 0; then
|
|||
(( ++version ))
|
||||
|
||||
case "$semver" in
|
||||
major ) version="${BASH_REMATCH[1]}$version.0.0${BASH_REMATCH[5]}" ;;
|
||||
minor ) version="${BASH_REMATCH[1]}${BASH_REMATCH[2]}.$version.0${BASH_REMATCH[5]}" ;;
|
||||
patch ) version="${BASH_REMATCH[1]}${BASH_REMATCH[2]}.${BASH_REMATCH[3]}.$version${BASH_REMATCH[5]}" ;;
|
||||
major ) version="$prefix${BASH_REMATCH[1]}$version.0.0${BASH_REMATCH[5]}" ;;
|
||||
minor ) version="$prefix${BASH_REMATCH[1]}${BASH_REMATCH[2]}.$version.0${BASH_REMATCH[5]}" ;;
|
||||
patch ) version="$prefix${BASH_REMATCH[1]}${BASH_REMATCH[2]}.${BASH_REMATCH[3]}.$version${BASH_REMATCH[5]}" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ _git-release() {
|
|||
'-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.]' \
|
||||
'--prefix[Add a prefix string to semver to allow more complex tags.]' \
|
||||
'--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.]'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-RELEASE" "1" "April 2018" "" "Git Extras"
|
||||
.TH "GIT\-RELEASE" "1" "April 2022" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\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] [\-s] [\-u <key-id>] [[\-\-] <hook arguments\.\.\.>]
|
||||
\fBgit\-release\fR [<tagname> | \-\-semver <name>] [\-r <remote>] [\-m <commit info>] [\-\-no\-empty\-commit] [\-c] [\-s] [\-u <key\-id>] [\-\-prefix <tag prefix>] [[\-\-] <hook arguments\.\.\.>]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Commits changes with message "Release <tagname>" or custom commit information, tags with the given <tagname> and pushes the branch / tags\.
|
||||
|
|
@ -25,7 +25,7 @@ If \fB\.git/hook/pre\-release\fR or \fB\.git/hook/post\-release\fR exist, they w
|
|||
\-\-semver <name>
|
||||
.
|
||||
.P
|
||||
If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag with this option\. The name must be one of the \fBmajor\fR, \fBminor\fR, \fBpatch\fR\. For example, assumed the latest tag is \fB4\.4\.0\fR, with \fBgit release \-\-semver minor\fR you will make a new release with tag \fB4\.5\.0\fR\.
|
||||
If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag with this option\. The name must be one of the \fBmajor\fR, \fBminor\fR, \fBpatch\fR\. For example, assumed the latest tag is \fB4\.4\.0\fR, with \fBgit release \-\-semver minor\fR you will make a new release with tag \fB4\.5\.0\fR\. Use \fB\-\-prefix\fR if tag has a character before semver\.
|
||||
.
|
||||
.P
|
||||
<tagname>
|
||||
|
|
@ -34,6 +34,12 @@ If the latest tag in your repo matches the semver format requirement, you could
|
|||
The name of the newly created tag\. Also used in tag comment\.
|
||||
.
|
||||
.P
|
||||
\-\-prefix <tag prefix>
|
||||
.
|
||||
.P
|
||||
Use a prefix with a semver tag\. \fBgit release \-\-semver minor \-\-prefix r\fR would increment the latest tag r4\.4\.0 to r4\.5\.0\. This prefix can be any length, without spaces\.
|
||||
.
|
||||
.P
|
||||
\-r <remote>
|
||||
.
|
||||
.P
|
||||
|
|
@ -64,7 +70,7 @@ Generates or populates the changelog with all commit message since the last tag\
|
|||
Create a signed and annotated tag\.
|
||||
.
|
||||
.P
|
||||
\-u <key ID>
|
||||
\-u <key\-id>
|
||||
.
|
||||
.P
|
||||
Create a tag, annotated and signed with the given key\.
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-release</code> [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [-s] [-u <key-id>] [[--] <hook arguments...>]</p>
|
||||
<p><code>git-release</code> [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [-s] [-u <key-id>] [--prefix <tag prefix>] [[--] <hook arguments...>]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
|
|
@ -94,12 +94,17 @@
|
|||
|
||||
<p> If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag
|
||||
with this option. The name must be one of the <code>major</code>, <code>minor</code>, <code>patch</code>. For example, assumed the latest tag is <code>4.4.0</code>, with
|
||||
<code>git release --semver minor</code> you will make a new release with tag <code>4.5.0</code>.</p>
|
||||
<code>git release --semver minor</code> you will make a new release with tag <code>4.5.0</code>. Use <code>--prefix</code> if tag has a character before semver.</p>
|
||||
|
||||
<p> <tagname></p>
|
||||
|
||||
<p> The name of the newly created tag. Also used in tag comment.</p>
|
||||
|
||||
<p> --prefix <tag prefix></p>
|
||||
|
||||
<p> Use a prefix with a semver tag. <code>git release --semver minor --prefix r</code> would increment the latest tag r4.4.0 to r4.5.0. This prefix
|
||||
can be any length, without spaces.</p>
|
||||
|
||||
<p> -r <remote></p>
|
||||
|
||||
<p> The "remote" repository that is destination of a push operation: it is passed to git push.</p>
|
||||
|
|
@ -155,8 +160,8 @@ populate changelog, and push to specific remote.</p>
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Tj Holowaychuk <<a href="mailto:tj@vision-media.ca" data-bare-link="true">tj@vision-media.ca</a>>
|
||||
Extended by David Hartmann <<a href="mailto:dh@tsl.io" data-bare-link="true">dh@tsl.io</a>></p>
|
||||
<p>Written by Tj Holowaychuk <<a href="mailto:tj@vision-media.ca" data-bare-link="true">tj@vision-media.ca</a>>
|
||||
Extended by David Hartmann <<a href="mailto:dh@tsl.io" data-bare-link="true">dh@tsl.io</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -169,7 +174,7 @@ Extended by David Hartmann <<a href="mailto:
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>April 2018</li>
|
||||
<li class='tc'>April 2022</li>
|
||||
<li class='tr'>git-release(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-release(1) -- Commit, tag and push changes to the repository
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-release` [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [-s] [-u <key-id>] [[--] <hook arguments...>]
|
||||
`git-release` [<tagname> | --semver <name>] [-r <remote>] [-m <commit info>] [--no-empty-commit] [-c] [-s] [-u <key-id>] [--prefix <tag prefix>] [[--] <hook arguments...>]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
|
|
@ -21,12 +21,17 @@ git-release(1) -- Commit, tag and push changes to the repository
|
|||
|
||||
If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag
|
||||
with this option. The name must be one of the `major`, `minor`, `patch`. For example, assumed the latest tag is `4.4.0`, with
|
||||
`git release --semver minor` you will make a new release with tag `4.5.0`.
|
||||
`git release --semver minor` you will make a new release with tag `4.5.0`. Use `--prefix` if tag has a character before semver.
|
||||
|
||||
<tagname>
|
||||
|
||||
The name of the newly created tag. Also used in tag comment.
|
||||
|
||||
--prefix <tag prefix>
|
||||
|
||||
Use a prefix with a semver tag. `git release --semver minor --prefix r` would increment the latest tag r4.4.0 to r4.5.0. This prefix
|
||||
can be any length, without spaces.
|
||||
|
||||
-r <remote>
|
||||
|
||||
The "remote" repository that is destination of a push operation: it is passed to git push.
|
||||
|
|
|
|||
Loading…
Reference in a new issue