Skip to content

Commit 94be404

Browse files
committed
Merge branch 'feature/issue-50' into develop
2 parents 8124333 + 5b200ca commit 94be404

8 files changed

+349
-1
lines changed

git-flow-release

+193-1
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

@@ -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>]
+22
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
+22
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
+22
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

+21
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

hooks/post-flow-release-create

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
#
3+
# Runs at the end of git flow release create start
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+
# $4 The base from which this release is started
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+
ORIGIN=$2
18+
BRANCH=$3
19+
BASE=$4
20+
21+
# Implement your script here.
22+
23+
exit 0

hooks/pre-flow-create-finish

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
#
3+
# Runs before 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+
# To terminate the git-flow action, return a non-zero exit code.
22+
exit 0

hooks/pre-flow-release-create

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
#
3+
# Runs before git flow release create start
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+
# $4 The base from which this release is started
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+
ORIGIN=$2
18+
BRANCH=$3
19+
BASE=$4
20+
21+
# Implement your script here.
22+
23+
# To terminate the git-flow action, return a non-zero exit code.
24+
exit 0

0 commit comments

Comments
 (0)