diff --git a/bin/git-release b/bin/git-release index 194876ec7..d46831132 100755 --- a/bin/git-release +++ b/bin/git-release @@ -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 diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index a6c7fe91b..f32d54a2f 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -291,6 +291,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.]' } diff --git a/man/git-release.1 b/man/git-release.1 index a070a2035..bbaddea07 100644 --- a/man/git-release.1 +++ b/man/git-release.1 @@ -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 [ | \-\-semver ] [\-r ] [\-m ] [\-\-no\-empty\-commit] [\-c] [\-s] [\-u ] [[\-\-] ] +\fBgit\-release\fR [ | \-\-semver ] [\-r ] [\-m ] [\-\-no\-empty\-commit] [\-c] [\-s] [\-u ] [\-\-prefix ] [[\-\-] ] . .SH "DESCRIPTION" Commits changes with message "Release " or custom commit information, tags with the given 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 . .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 @@ -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 +. +.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 . .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 +\-u . .P Create a tag, annotated and signed with the given key\. diff --git a/man/git-release.html b/man/git-release.html index 3e30b881d..fb95247cd 100644 --- a/man/git-release.html +++ b/man/git-release.html @@ -76,7 +76,7 @@

NAME

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

@@ -94,12 +94,17 @@

OPTIONS

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.

@@ -155,8 +160,8 @@

EXAMPLES

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

@@ -169,7 +174,7 @@

SEE ALSO

  1. -
  2. April 2018
  3. +
  4. April 2022
  5. git-release(1)
diff --git a/man/git-release.md b/man/git-release.md index 0e7b2f430..f68465e32 100644 --- a/man/git-release.md +++ b/man/git-release.md @@ -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.