3636# policies, either expressed or implied, of Vincent Driessen.
3737#
3838
39- require_git_repo
40- require_gitflow_initialized
41- gitflow_load_settings
42- VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
43- PREFIX=$(git config --get gitflow.prefix.release)
39+ init() {
40+   require_git_repo
41+   require_gitflow_initialized
42+   gitflow_load_settings
43+   VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
44+   PREFIX=$(git config --get gitflow.prefix.release)
45+ }
4446
4547usage() {
4648	echo "usage: git flow release [list] [-v]"
4749	echo "       git flow release start [-F] <version> [<base>]"
48- 	echo "       git flow release finish [-Fsumpk ] <version>"
50+ 	echo "       git flow release finish [-FsumpkS ] <version>"
4951	echo "       git flow release publish <name>"
5052	echo "       git flow release track <name>"
5153}
@@ -190,9 +192,11 @@ cmd_finish() {
190192	DEFINE_boolean sign false "sign the release tag cryptographically" s
191193	DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
192194	DEFINE_string message "" "use the given tag message" m
195+ 	DEFINE_string messagefile "" "use the contents of the given file as a tag message" f
193196	DEFINE_boolean push false "push to $ORIGIN after performing finish" p
194197	DEFINE_boolean keep false "keep branch after performing finish" k
195198	DEFINE_boolean notag false "don't tag this release" n
199+ 	DEFINE_boolean squash false "squash release during merge" S
196200
197201	parse_args "$@"
198202	require_version_arg
@@ -224,9 +228,15 @@ cmd_finish() {
224228	if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
225229		git checkout "$MASTER_BRANCH" || \
226230		  die "Could not check out $MASTER_BRANCH."
227- 		git merge --no-ff "$BRANCH" || \
228- 		  die "There were merge conflicts."
229- 		  # TODO: What do we do now?
231+ 		if noflag squash; then
232+ 			git merge --no-ff "$BRANCH" || \
233+ 				die "There were merge conflicts."
234+ 				# TODO: What do we do now?
235+ 		else
236+ 			git merge --squash "$BRANCH" || \
237+ 				die "There were merge conflicts."
238+ 			git commit
239+ 		fi
230240	fi
231241
232242	if noflag notag; then
@@ -239,6 +249,7 @@ cmd_finish() {
239249			flag sign && opts="$opts -s"
240250			[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
241251			[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
252+ 			[ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
242253			eval git tag $opts "$tagname" "$BRANCH" || \
243254			die "Tagging failed. Please run finish again to retry."
244255		fi
@@ -253,9 +264,16 @@ cmd_finish() {
253264
254265		# TODO: Actually, accounting for 'git describe' pays, so we should
255266		# ideally git merge --no-ff $tagname here, instead!
256- 		git merge --no-ff "$BRANCH" || \
257- 		  die "There were merge conflicts."
258- 		  # TODO: What do we do now?
267+ 		if noflag squash; then
268+ 			git merge --no-ff "$BRANCH" || \
269+ 				die "There were merge conflicts."
270+ 				# TODO: What do we do now?
271+ 		else
272+ 			git merge --squash "$BRANCH" || \
273+ 				die "There were merge conflicts."
274+ 				# TODO: What do we do now?
275+ 			git commit
276+ 		fi
259277	fi
260278
261279	# delete branch
0 commit comments