Skip to content
This repository

Add archival feature tagging on feature finish #236

Closed
wants to merge 1 commit into from

1 participant

Fred Condo
Fred Condo
oddnoc commented

When finishing a feature, add a tag with the feature name, prefixed with
the configured archive prefix. Example: a feature named foo would be
archived as archive/feature/foo. The tag is set immediately behind the
merge commit

Having such tags eases resumption of feature branches that are
prematurely finished. They also mark the end of each feature branch in a
way that's easier to find than searching for the final merge commit.

Add a flag to feature finish, -A, that enables archive tagging if it is
not on by default in the config.

Add a new boolean configuration option, gitflow.options.archivefeatures,
which if set true, archives features by default, without specifying -A
on the command line.

Add a new prefix in git flow init: gitflow.prefix.archivetag, with
default archive/

Add a summary message if branch was archive tagged.

Fred Condo Add archival feature tagging on feature finish
When finishing a feature, add a tag with the feature name, prefixed with
the configured archive prefix. Example: a feature named foo would be
archived as archive/feature/foo. The tag is set immediately behind the
merge commit

Having such tags eases resumption of feature branches that are
prematurely finished. They also mark the end of each feature branch in a
way that's easier to find than searching for the final merge commit.

Add a flag to feature finish, -A, that enables archive tagging if it is
not on by default in the config.

Add a new boolean configuration option, gitflow.options.archivefeatures,
which if set true, archives features by default, without specifying -A
on the command line.

Add a new prefix in git flow init: gitflow.prefix.archivetag, with
default archive/

Add a summary message if branch was archive tagged.
97edadc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 09, 2013
Fred Condo Add archival feature tagging on feature finish
When finishing a feature, add a tag with the feature name, prefixed with
the configured archive prefix. Example: a feature named foo would be
archived as archive/feature/foo. The tag is set immediately behind the
merge commit

Having such tags eases resumption of feature branches that are
prematurely finished. They also mark the end of each feature branch in a
way that's easier to find than searching for the final merge commit.

Add a flag to feature finish, -A, that enables archive tagging if it is
not on by default in the config.

Add a new boolean configuration option, gitflow.options.archivefeatures,
which if set true, archives features by default, without specifying -A
on the command line.

Add a new prefix in git flow init: gitflow.prefix.archivetag, with
default archive/

Add a summary message if branch was archive tagged.
97edadc
This page is out of date. Refresh to see the latest.
2  git-flow
@@ -114,7 +114,7 @@ main() {
114 114 fi
115 115
116 116 # run the specified action
117   - if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ] ; then
  117 + if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ] && [ $SUBCOMMAND != "version" ] ; then
118 118 init
119 119 fi
120 120 cmd_$SUBACTION "$@"
27 git-flow-feature
@@ -46,7 +46,7 @@ init() {
46 46 usage() {
47 47 echo "usage: git flow feature [list] [-v]"
48 48 echo " git flow feature start [-F] <name> [<base>]"
49   - echo " git flow feature finish [-rFkDS] [<name|nameprefix>]"
  49 + echo " git flow feature finish [-rFkDSA] [<name|nameprefix>]"
50 50 echo " git flow feature publish <name>"
51 51 echo " git flow feature track <name>"
52 52 echo " git flow feature diff [<name|nameprefix>]"
@@ -235,6 +235,7 @@ cmd_finish() {
235 235 DEFINE_boolean keep false "keep branch after performing finish" k
236 236 DEFINE_boolean force_delete false "force delete feature branch after finish" D
237 237 DEFINE_boolean squash false "squash feature during merge" S
  238 + DEFINE_boolean archivefeature false "create archive tag for feature" A
238 239 parse_args "$@"
239 240 expand_nameprefix_arg_or_current
240 241
@@ -310,6 +311,27 @@ cmd_finish() {
310 311 fi
311 312 fi
312 313
  314 + # Tag the head of the feature branch for the archives
  315 + if flag archivefeature || [ "true" = "$(git config --bool gitflow.options.archivefeatures)" ]; then
  316 + if ! ARCHIVE_PREFIX=$(git config --get gitflow.prefix.archivetag); then
  317 + warn "You have not set an archive prefix. Please set"
  318 + warn "gitflow.prefix.archivetag in your config (default archive/)."
  319 + exit 1
  320 + fi
  321 + local TAG="$ARCHIVE_PREFIX$BRANCH"
  322 + if ! git tag -am "$BRANCH" "$TAG" "$BRANCH"; then
  323 + warn "Finish was aborted because the archive tag could not be added."
  324 + warn "You must provide a tag message. If the tag already exists, read on."
  325 + warn "You may wish to delete or rename a previous version of the tag."
  326 + warn "To delete it, do this:"
  327 + warn " git tag -d $TAG"
  328 + warn "To rename it, do this:"
  329 + warn " git tag -a ${TAG}_new_name $TAG"
  330 + warn "then delete it as shown above."
  331 + exit 1
  332 + fi
  333 + fi
  334 +
313 335 # merge into BASE
314 336 git_do checkout "$DEVELOP_BRANCH"
315 337 if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
@@ -372,6 +394,9 @@ helper_finish_cleanup() {
372 394 else
373 395 echo "- Feature branch '$BRANCH' has been removed"
374 396 fi
  397 + if flag archivefeature || [ "true" = "$(git config --bool gitflow.options.archivefeatures)" ]; then
  398 + echo "- Feature branch '$BRANCH' has been archived as a tag"
  399 + fi
375 400 echo "- You are now on branch '$DEVELOP_BRANCH'"
376 401 echo
377 402 }
29 git-flow-init
@@ -234,6 +234,7 @@ cmd_default() {
234 234 ! git config --get gitflow.prefix.release >/dev/null 2>&1 ||
235 235 ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 ||
236 236 ! git config --get gitflow.prefix.support >/dev/null 2>&1 ||
  237 + ! git config --get gitflow.prefix.archivetag >/dev/null 2>&1 ||
237 238 ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1; then
238 239 echo
239 240 echo "How to name your supporting branch prefixes?"
@@ -310,6 +311,34 @@ cmd_default() {
310 311 fi
311 312
312 313
  314 + # Archive tag prefix
  315 + if ! git config --get gitflow.prefix.archivetag >/dev/null 2>&1 || flag force; then
  316 + default_suggestion=$(git config --get gitflow.prefix.archivetag || echo archive/)
  317 + printf "Archive tag prefix? [$default_suggestion] "
  318 + if noflag defaults; then
  319 + read answer
  320 + else
  321 + printf "\n"
  322 + fi
  323 + [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
  324 + git config gitflow.prefix.archivetag "$prefix"
  325 + fi
  326 +
  327 +
  328 + # Archive tag prefix
  329 + if ! git config --get gitflow.prefix.archivetag >/dev/null 2>&1 || flag force; then
  330 + default_suggestion=$(git config --get gitflow.prefix.archivetag || echo archive/)
  331 + printf "Archive tag prefix? [$default_suggestion] "
  332 + if noflag defaults; then
  333 + read answer
  334 + else
  335 + printf "\n"
  336 + fi
  337 + [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
  338 + git config gitflow.prefix.archivetag "$prefix"
  339 + fi
  340 +
  341 +
313 342 # TODO: what to do with origin?
314 343 }
315 344
2  git-flow-version
@@ -36,7 +36,7 @@
36 36 # policies, either expressed or implied, of Vincent Driessen.
37 37 #
38 38
39   -GITFLOW_VERSION=0.4.2-pre
  39 +GITFLOW_VERSION=0.4.1-true-111-g33b2f93+archive-tagging
40 40
41 41 usage() {
42 42 echo "usage: git flow version"

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.