Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get our finish version number guess from branch.

Previous versions attempted to guess version number on finish
based on version number auto-incrementation. It's more intuitive
to guess based on current branch on finish as that honors a user
override of default version number incrementation on release or
hotfix start.
  • Loading branch information...
commit c81941fffcf0361ddfa2757b2f275d6caaa65b13 1 parent bba9408
Nickolas Means authored
Showing with 28 additions and 2 deletions.
  1. +12 −1 git-flow-hotfix
  2. +12 −1 git-flow-release
  3. +4 −0 gitflow-common
View
13 git-flow-hotfix
@@ -138,6 +138,17 @@ require_version_arg() {
fi
}
+require_version_arg_for_finish() {
+ if [ "$VERSION" = "" ]; then
+ default_suggestion="$(gitflow_current_version_from_branch_name)"
+ printf "Version number for this release: [$default_suggestion] "
+ read answer
+ VERSION=${answer:-$default_suggestion}
+ BRANCH=$PREFIX$VERSION
+ require_branch $BRANCH
+ fi
+}
+
require_base_is_on_master() {
if ! git branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \
@@ -199,7 +210,7 @@ cmd_finish() {
DEFINE_boolean keep false "keep branch after performing finish" k
DEFINE_boolean notag false "don't tag this release" n
parse_args "$@"
- require_version_arg
+ require_version_arg_for_finish
# handle flags that imply other flags
if [ "$FLAGS_signingkey" != "" ]; then
View
13 git-flow-release
@@ -135,6 +135,17 @@ require_version_arg() {
fi
}
+require_version_arg_for_finish() {
+ if [ "$VERSION" = "" ]; then
+ default_suggestion="$(gitflow_current_version_from_branch_name)"
+ printf "Version number for this release: [$default_suggestion] "
+ read answer
+ VERSION=${answer:-$default_suggestion}
+ BRANCH=$PREFIX$VERSION
+ require_branch $BRANCH
+ fi
+}
+
require_base_is_on_develop() {
if ! git branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \
@@ -197,7 +208,7 @@ cmd_finish() {
DEFINE_boolean notag false "don't tag this release" n
parse_args "$@"
- require_version_arg
+ require_version_arg_for_finish
# handle flags that imply other flags
if [ "$FLAGS_signingkey" != "" ]; then
View
4 gitflow-common
@@ -320,6 +320,10 @@ require_branches_equal() {
# Functions for auto version incrementing
#
+gitflow_current_version_from_branch_name() {
+ echo "$(git_current_branch)" | sed 's/.*\/\(.*\)/\1/g'
+}
+
git_current_version() {
echo "$(git_all_tags_by_date)" | grep -e '.*[0-9]*\.[0-9]*\.[0-9].*' | sed '$!d' | sed -n 's/[^0-9]*\([0-9]*.[0-9]*.[0-9]\)[^0-9]*/\1/p'
}
Please sign in to comment.
Something went wrong with that request. Please try again.