Skip to content

Commit d752862

Browse files
committed
chore(release): v2.1.0
* feat: add create command to release allowing for a single step release prodution * feat: add missing hook script filter-flow-release-finish-version * fix: multi-line tag message when using -m * docs: update readme with better description as to why this fork was created. Thank You [shaedrick](https://github.com/shaedrich)
2 parents fddb161 + 60011bf commit d752862

12 files changed

+366
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
#### 2.1.0
4+
* feat: add create command to release allowing for a single step release prodution
5+
* feat: add missing hook script filter-flow-release-finish-version
6+
* fix: multi-line tag message when using -m
7+
* docs: update readme with better description as to why this fork was created. Thank You [shaedrick](https://github.com/shaedrich)
8+
**NOTE:** The format for a multi-line tag message is now "$(printf 'line of text with \n escape codes placed as needed for proper formating of the message')"
9+
10+
311
#### 2.0.1
412
* fix incorrect version identification along with updating source repository in gitflow-installer. Corrections pointed out by [bobstuart](https://github.com/bobstuart)
513

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ blog post"). This fork adds functionality not added to the original branch.
66

77
## Why another git-flow fork
88
The last commit to [gitflow-avh](https://github.com/petervanderdoes/gitflow-avh)
9-
was on May 23, 2019. Since then there have been a number of issues opened that have
10-
not be resolved. This fork will address those outstanding issues and open PR's along
11-
with continueing to maintain the git-flow branching model.
9+
was on May 23, 2019 and has been archived on Jun 19, 2023. Since 2019 there have
10+
been a number of issues opened that have not be resolved. This fork will address
11+
those outstanding issues and open PR's along with continueing to maintain the
12+
git-flow branching model.
1213

1314
## Getting started
1415

git-flow-hotfix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ T,tagname! Use given tag name
547547
opts="$opts -m '$FLAGS_message'"
548548
fi
549549
[ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
550-
eval git_do tag $opts "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry."
550+
eval git_do tag "$opts" "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry."
551551
fi
552552
fi
553553

git-flow-release

Lines changed: 196 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#
4444
_finish_from_develop() {
4545
local opts merge_branch commit keepmsg remotebranchdeleted localbranchdeleted compare_refs_result merge_result
46-
46+
4747
remotebranchdeleted=$FLAGS_FALSE
4848
localbranchdeleted=$FLAGS_FALSE
4949

@@ -140,7 +140,7 @@ _finish_from_develop() {
140140
opts="$opts -m $VERSION_PREFIX$TAGNAME"
141141
fi
142142
fi
143-
eval git_do tag $opts "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry."
143+
eval git_do tag "$opts" "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry."
144144
fi
145145
fi
146146

@@ -342,7 +342,7 @@ _finish_base() {
342342
opts="$opts -m $VERSION_PREFIX$TAGNAME"
343343
fi
344344
fi
345-
eval git_do tag $opts "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry."
345+
eval git_do tag "$opts" "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry."
346346
fi
347347
fi
348348

@@ -439,6 +439,7 @@ git flow release publish
439439
git flow release track
440440
git flow release rebase
441441
git flow release delete
442+
git flow release create
442443
443444
Manage your release branches.
444445
@@ -548,6 +549,197 @@ require_no_existing_release_branches() {
548549
[ -z "$release_branches" ] || die "There is an existing release branch '$first_branch'. Finish that one first."
549550
}
550551

552+
cmd_create() {
553+
OPTIONS_SPEC="\
554+
git flow release create [options] <version> [<base>]
555+
556+
Create a new release branch
557+
--
558+
h,help Show this help
559+
showcommands! Show git commands while executing them
560+
F,[no]fetch Fetch from origin before performing finish
561+
s,sign! Sign the release tag cryptographically
562+
u,signingkey! Use the given GPG-key for the digital signature (implies -s)
563+
m,message! Use the given tag message
564+
f,[no]messagefile= Use the contents of the given file as a tag message
565+
p,[no]push Push to origin after performing finish
566+
[no]pushproduction Push the production branch
567+
[no]pushdevelop Push the develop branch
568+
[no]pushtag Push the tag
569+
k,[no]keep Keep branch after performing finish
570+
[no]keepremote Keep the remote branch
571+
[no]keeplocal Keep the local branch
572+
D,[no]force_delete Force delete release branch after finish
573+
n,[no]tag Don't tag this release
574+
b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop
575+
S,[no]squash Squash release during merge
576+
[no]ff-master Fast forward master branch if possible
577+
e,[no]edit The --noedit option can be used to accept the auto-generated message on merging
578+
T,tagname! Use given tag name
579+
nodevelopmerge! Don't back-merge develop branch
580+
"
581+
582+
local base
583+
584+
# Define flags
585+
DEFINE_boolean 'fetch' false "fetch from $ORIGIN before performing finish" F
586+
DEFINE_boolean 'sign' false "sign the release tag cryptographically" s
587+
DEFINE_string 'signingkey' "" "use the given GPG-key for the digital signature (implies -s)" u
588+
DEFINE_string 'message' "" "use the given tag message" m
589+
DEFINE_string 'messagefile' "" "use the contents of the given file as a tag message" f
590+
DEFINE_boolean 'push' false "push to $ORIGIN after performing finish" p
591+
DEFINE_boolean 'pushproduction' false "push the production branch"
592+
DEFINE_boolean 'pushdevelop' false "push the develop branch"
593+
DEFINE_boolean 'pushtag' false "push the tag"
594+
DEFINE_boolean 'keep' false "keep branch after performing finish" k
595+
DEFINE_boolean 'keepremote' false "keep the remote branch"
596+
DEFINE_boolean 'keeplocal' false "keep the local branch"
597+
DEFINE_boolean 'force_delete' false "force delete release branch after finish" D
598+
DEFINE_boolean 'notag' false "don't tag this release" n
599+
DEFINE_boolean 'nobackmerge' false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b
600+
DEFINE_boolean 'squash' false "squash release during merge" S
601+
DEFINE_boolean 'squash-info' false "add branch info during squash"
602+
DEFINE_boolean 'ff-master' false "fast forward master branch if possible"
603+
DEFINE_boolean 'edit' true "accept the auto-generated message on merging" e
604+
DEFINE_string 'tagname' "" "use the given tag name" T
605+
DEFINE_boolean 'nodevelopmerge' false "don't merge $BRANCH into $DEVELOP_BRANCH "
606+
607+
# Override defaults with values from config
608+
gitflow_override_flag_boolean "release.finish.fetch" "fetch"
609+
gitflow_override_flag_boolean "release.finish.sign" "sign"
610+
gitflow_override_flag_boolean "release.finish.push" "push"
611+
gitflow_override_flag_boolean "release.finish.pushproduction" "pushproduction"
612+
gitflow_override_flag_boolean "release.finish.pushdevelop" "pushdevelop"
613+
gitflow_override_flag_boolean "release.finish.pushtag" "pushtag"
614+
gitflow_override_flag_boolean "release.finish.keep" "keep"
615+
gitflow_override_flag_boolean "release.finish.keepremote" "keepremote"
616+
gitflow_override_flag_boolean "release.finish.keeplocal" "keeplocal"
617+
gitflow_override_flag_boolean "release.finish.force-delete" "force_delete"
618+
gitflow_override_flag_boolean "release.finish.notag" "notag"
619+
gitflow_override_flag_boolean "release.finish.nobackmerge" "nobackmerge"
620+
gitflow_override_flag_boolean "release.finish.squash" "squash"
621+
gitflow_override_flag_boolean "release.finish.squash-info" "squash_info"
622+
gitflow_override_flag_boolean "release.finish.ff-master" "ff-master"
623+
gitflow_override_flag_string "release.finish.signingkey" "signingkey"
624+
gitflow_override_flag_string "release.finish.message" "message"
625+
gitflow_override_flag_string "release.finish.messagefile" "messagefile"
626+
gitflow_override_flag_boolean "release.finish.nodevelopmerge" "nodevelopmerge"
627+
628+
629+
630+
parse_args "$@"
631+
eval set -- "${FLAGS_ARGV}"
632+
633+
base=${2:-$DEVELOP_BRANCH}
634+
# Run filter on the version
635+
VERSION=$(run_filter_hook create-start-version $VERSION)
636+
if [ $? -eq 127 ]; then
637+
die $VERSION
638+
fi
639+
640+
# As VERSION might have changed reset BRANCH with new VERSION
641+
BRANCH=$PREFIX$VERSION
642+
643+
require_base_is_local_branch "$base"
644+
gitflow_require_version_arg
645+
646+
require_no_existing_release_branches
647+
648+
# Sanity checks
649+
git_config_bool_exists "gitflow.allowdirty" || require_clean_working_tree
650+
require_branch_absent "$BRANCH"
651+
require_tag_absent "$VERSION_PREFIX$VERSION"
652+
if flag fetch; then
653+
git_fetch_branch "$ORIGIN" "$base"
654+
fi
655+
if git_remote_branch_exists "$ORIGIN/$base"; then
656+
require_branches_equal "$base" "$ORIGIN/$base"
657+
fi
658+
659+
run_pre_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" "$base"
660+
661+
gitflow_config_set_base_branch $base $BRANCH
662+
663+
# Create branch
664+
git_do checkout -b "$BRANCH" "$base" || die "Could not create release branch '$BRANCH'."
665+
666+
run_post_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" "$base"
667+
668+
echo
669+
echo "Summary of actions:"
670+
echo "- A new branch '$BRANCH' was created, based on '$base'"
671+
echo "- You are now on branch '$(git_current_branch)'"
672+
echo
673+
echo "Follow-up actions:"
674+
echo "- Bump the version number now!"
675+
echo "- Start committing last-minute fixes in preparing your release"
676+
echo "- When done, run:"
677+
echo
678+
echo " git flow release finish '$VERSION'"
679+
echo
680+
# Run filter on the version
681+
VERSION=$(run_filter_hook create-finish-version $VERSION)
682+
if [ $? -eq 127 ]; then
683+
die $VERSION
684+
fi
685+
686+
# Use branch name if no tag name is given
687+
if [ "$FLAGS_tagname" != "" ]; then
688+
TAGNAME=$FLAGS_tagname
689+
else
690+
TAGNAME=$VERSION
691+
fi
692+
693+
# As VERSION might have changed reset BRANCH with new VERSION
694+
BRANCH=$PREFIX$VERSION
695+
696+
BASE_BRANCH=$(gitflow_config_get_base_branch $BRANCH)
697+
BASE_BRANCH=${BASE_BRANCH:-$DEVELOP_BRANCH}
698+
git_local_branch_exists "$BASE_BRANCH" || die "The base '$BASE_BRANCH' doesn't exists locally or is not a branch. Can't finish the release branch '$BRANCH'."
699+
700+
# Handle flags that imply other flags
701+
if [ "$FLAGS_signingkey" != "" ]; then
702+
FLAGS_sign=$FLAGS_TRUE
703+
fi
704+
705+
# Keeping both branches implies the --keep flag to be true.
706+
if flag keepremote && flag keeplocal; then
707+
FLAGS_keep=$FLAGS_TRUE
708+
fi
709+
710+
# Pushing implies we push all.
711+
if flag push; then
712+
FLAGS_pushproduction=$FLAGS_TRUE
713+
FLAGS_pushdevelop=$FLAGS_TRUE
714+
FLAGS_pushtag=$FLAGS_TRUE
715+
fi
716+
# If we push either of these it means we need to do a push
717+
if flag pushproduction || flag pushdevelop || flag pushtag; then
718+
FLAGS_push=$FLAGS_TRUE
719+
fi
720+
721+
# Sanity checks
722+
require_branch "$BRANCH"
723+
require_clean_working_tree
724+
725+
# We always fetch the Branch from Origin
726+
# This is done to avoid possible commits on the remote that are not
727+
# merged into the local branch
728+
if git_remote_branch_exists "$ORIGIN/$BRANCH"; then
729+
git_fetch_branch "$ORIGIN" "$BRANCH"
730+
fi
731+
732+
if [ "$BASE_BRANCH" = "$DEVELOP_BRANCH" ]; then
733+
SUBCOMMAND="create"
734+
SUBACTION="finish"
735+
_finish_from_develop
736+
else
737+
SUBCOMMAND="create"
738+
SUBACTION="finish"
739+
_finish_base
740+
fi
741+
}
742+
551743
cmd_start() {
552744
OPTIONS_SPEC="\
553745
git flow release start [options] <version> [<base>]
@@ -889,7 +1081,7 @@ S,[no]squash Squash release during merge
8891081
opts="$opts -m '$FLAGS_message'"
8901082
fi
8911083
[ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
892-
eval git_do tag $opts "$VERSION_PREFIX$VERSION" || die "Tagging failed. Please run finish again to retry."
1084+
eval git_do tag "$opts" "$VERSION_PREFIX$VERSION" || die "Tagging failed. Please run finish again to retry."
8931085
fi
8941086
fi
8951087

git-flow-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#
3939

4040

41-
GITFLOW_VERSION=2.0.1
41+
GITFLOW_VERSION=2.1.0
4242

4343
initialize() {
4444
# A function can not be empty. Comments count as empty.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
#
3+
# Runs during git flow release create finish
4+
#
5+
# Positional arguments:
6+
# $1 Version
7+
#
8+
# Return VERSION - When VERSION is returned empty, git-flow will stop as the
9+
# version is necessary
10+
#
11+
# The following variables are available as they are exported by git-flow:
12+
#
13+
# MASTER_BRANCH - The branch defined as Master
14+
# DEVELOP_BRANCH - The branch defined as Develop
15+
#
16+
VERSION=$1
17+
18+
# Implement your script here.
19+
20+
# Return the VERSION
21+
echo ${VERSION}
22+
exit 0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
#
3+
# Runs during git flow release create start
4+
#
5+
# Positional arguments:
6+
# $1 Version
7+
#
8+
# Return VERSION - When VERSION is returned empty, git-flow will stop as the
9+
# version is necessary
10+
#
11+
# The following variables are available as they are exported by git-flow:
12+
#
13+
# MASTER_BRANCH - The branch defined as Master
14+
# DEVELOP_BRANCH - The branch defined as Develop
15+
#
16+
VERSION=$1
17+
18+
# Implement your script here.
19+
20+
# Return the VERSION
21+
echo ${VERSION}
22+
exit 0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
#
3+
# Runs during git flow release finish
4+
#
5+
# Positional arguments:
6+
# $1 Version
7+
#
8+
# Return VERSION - When VERSION is returned empty, git-flow will stop as the
9+
# version is necessary
10+
#
11+
# The following variables are available as they are exported by git-flow:
12+
#
13+
# MASTER_BRANCH - The branch defined as Master
14+
# DEVELOP_BRANCH - The branch defined as Develop
15+
#
16+
VERSION=$1
17+
18+
# Implement your script here.
19+
20+
# Return the VERSION
21+
echo ${VERSION}
22+
exit 0

hooks/post-flow-create-finish

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
#
3+
# Runs at the end of git flow release create finish
4+
#
5+
# Positional arguments:
6+
# $1 The version (including the version prefix)
7+
# $2 The origin remote
8+
# $3 The full branch name (including the release prefix)
9+
#
10+
# The following variables are available as they are exported by git-flow:
11+
#
12+
# MASTER_BRANCH - The branch defined as Master
13+
# DEVELOP_BRANCH - The branch defined as Develop
14+
#
15+
VERSION=$1
16+
ORIGIN=$2
17+
BRANCH=$3
18+
19+
# Implement your script here.
20+
21+
exit 0

0 commit comments

Comments
 (0)