Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement in-place release with -i/--inplace option

This implement a solution to issue #133 "Add ability to release directly
from develop".

When in-place is activated:

- the current branch must be merged in the develop branch
- no mergeback occurs
- no branch deletion occurs

The in-place release can be called in two ways:

    git flow release finish -i <version>

or a shorter form:

    git flow release -i <version>

* git-flow-release (cmd_default): Define flags of cmd_list() and
  cmd_finish() to support the shorter call form.
  Call cmd_finish() if inplace is enabled.
  (cmd_list): Avoid warning by redefining the verbose flag if called from
  cmd_default().
  (cmd_finish): Avoid warning by redefining flags if called from
  cmd_default().
  Add filter on the version.
  Do not merge back and delete branch when inplace is enabled
  • Loading branch information...
commit 8c1e1786a79b0a3fa8f2d7313ed8a8952b0532c1 1 parent 4a645d1
Daniel Dehennin authored

Showing 1 changed file with 62 additions and 20 deletions. Show diff stats Hide diff stats

  1. +62 20 git-flow-release
82 git-flow-release
@@ -51,11 +51,33 @@ usage() {
51 51 }
52 52
53 53 cmd_default() {
54   - cmd_list "$@"
  54 + # flags required for cmd_start
  55 + DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
  56 + DEFINE_boolean sign false "sign the release tag cryptographically" s
  57 + DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
  58 + DEFINE_string message "" "use the given tag message" m
  59 + DEFINE_boolean push false "push to $ORIGIN after performing finish" p
  60 + DEFINE_boolean keep false "keep branch after performing finish" k
  61 + DEFINE_boolean notag false "don't tag this release" n
  62 + DEFINE_boolean nobackmerge false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b
  63 + DEFINE_boolean inplace false "Release directly on the development branch" i
  64 + # flags required for cmd_list
  65 + DEFINE_boolean verbose false 'verbose (more) output' v
  66 +
  67 + FLAGS "$@"
  68 + if flag inplace; then
  69 + cmd_finish "$@"
  70 + else
  71 + cmd_list "$@"
  72 + fi
55 73 }
56 74
57 75 cmd_list() {
58   - DEFINE_boolean verbose false 'verbose (more) output' v
  76 + # cmd_default may already define flags
  77 + # at this stage we can not use parse_args
  78 + if [ -z "${FLAGS_verbose}" ]; then
  79 + DEFINE_boolean verbose false 'verbose (more) output' v
  80 + fi
59 81 parse_args "$@"
60 82
61 83 local release_branches
@@ -177,16 +199,32 @@ cmd_start() {
177 199 }
178 200
179 201 cmd_finish() {
180   - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
181   - DEFINE_boolean sign false "sign the release tag cryptographically" s
182   - DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
183   - DEFINE_string message "" "use the given tag message" m
184   - DEFINE_boolean push false "push to $ORIGIN after performing finish" p
185   - DEFINE_boolean keep false "keep branch after performing finish" k
186   - DEFINE_boolean notag false "don't tag this release" n
187   - DEFINE_boolean nobackmerge false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b
  202 + # cmd_default may already define flags
  203 + # at this stage we can not use parse_args
  204 + if [ -z "${FLAGS_inplace}" ]; then
  205 + DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
  206 + DEFINE_boolean sign false "sign the release tag cryptographically" s
  207 + DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
  208 + DEFINE_string message "" "use the given tag message" m
  209 + DEFINE_boolean push false "push to $ORIGIN after performing finish" p
  210 + DEFINE_boolean keep false "keep branch after performing finish" k
  211 + DEFINE_boolean notag false "don't tag this release" n
  212 + DEFINE_boolean nobackmerge false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b
  213 + DEFINE_boolean inplace false "Release directly on the development branch" i
  214 + fi
188 215
189 216 parse_args "$@"
  217 + # Run filter on the version
  218 + VERSION=$(run_filter_hook release-finish-version $VERSION)
  219 +
  220 + # As VERSION might have changed reset BRANCH with new VERSION
  221 + BRANCH=$PREFIX$VERSION
  222 +
  223 + if flag inplace; then
  224 + BASE="$(git_current_branch)"
  225 + git_is_ancestor "$BASE" "$DEVELOP_BRANCH" || die "Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'."
  226 + fi
  227 +
190 228 gitflow_require_version_arg
191 229
192 230 # Handle flags that imply other flags
@@ -210,13 +248,15 @@ cmd_finish() {
210 248
211 249 run_pre_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH"
212 250
213   - # Try to merge into master.
214   - # In case a previous attempt to finish this release branch has failed,
215   - # but the merge into master was successful, we skip it now
216   - if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
217   - git checkout "$MASTER_BRANCH" || die "Could not check out $MASTER_BRANCH."
218   - git merge --no-ff "$BRANCH" || die "There were merge conflicts."
219   - # TODO: What do we do now?
  251 + if noflag inplace; then
  252 + # Try to merge into master.
  253 + # In case a previous attempt to finish this release branch has failed,
  254 + # but the merge into master was successful, we skip it now
  255 + if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
  256 + git checkout "$MASTER_BRANCH" || die "Could not check out $MASTER_BRANCH."
  257 + git merge --no-ff "$BRANCH" || die "There were merge conflicts."
  258 + # TODO: What do we do now?
  259 + fi
220 260 fi
221 261
222 262
@@ -266,7 +306,7 @@ cmd_finish() {
266 306 run_post_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH"
267 307
268 308 # Delete branch
269   - if noflag keep; then
  309 + if noflag keep && noflag inplace; then
270 310 if [ "$BRANCH" = "$(git_current_branch)" ]; then
271 311 git checkout "$MASTER_BRANCH"
272 312 fi
@@ -285,7 +325,9 @@ cmd_finish() {
285 325 echo
286 326 echo "Summary of actions:"
287 327 echo "- Latest objects have been fetched from '$ORIGIN'"
288   - echo "- Release branch '$BRANCH' has been merged into '$MASTER_BRANCH'"
  328 + if noflag inplace; then
  329 + echo "- Release branch '$BRANCH' has been merged into '$MASTER_BRANCH'"
  330 + fi
289 331 if noflag notag; then
290 332 echo "- The release was tagged '$VERSION_PREFIX$VERSION'"
291 333 fi
@@ -294,7 +336,7 @@ cmd_finish() {
294 336 [ "$commit" = "$BRANCH" ] && echo "- Release branch '$BRANCH' has been merged into '$DEVELOP_BRANCH'"
295 337 if flag keep; then
296 338 echo "- Release branch '$BRANCH' is still available"
297   - else
  339 + elif noflag inplace; then
298 340 echo "- Release branch '$BRANCH' has been deleted"
299 341 fi
300 342 if flag push; then

0 comments on commit 8c1e178

Please sign in to comment.
Something went wrong with that request. Please try again.