Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add function gitflow_has_prefixes_configured(), to check whether a re…

…po is

fully initialized for use with gitflow.

Add a means of only asking for the missing gitflow definitions, not all.
(Of course, redefining all is always possible using the -f (--force) flag
of init.)
  • Loading branch information...
commit 1d8bb0d11ae3b937dd2de0e4406b82d64ddbcf52 1 parent 9ddb1dc
@nvie authored
Showing with 52 additions and 30 deletions.
  1. +39 −25 git-flow-init
  2. +13 −5 gitflow-common
View
64 git-flow-init
@@ -184,39 +184,53 @@ cmd_default() {
local prefix
# Feature branches
- default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/)
- echo "Feature branches? [$default_suggestion] \c"
- read answer
- [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.feature "$prefix"
+ if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/)
+ echo "Feature branches? [$default_suggestion] \c"
+ read answer
+ [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
+ git config gitflow.prefix.feature "$prefix"
+ fi
# Release branches
- default_suggestion=$(git config --get gitflow.prefix.release || echo release/)
- echo "Release branches? [$default_suggestion] \c"
- read answer
- [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.release "$prefix"
+ if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get gitflow.prefix.release || echo release/)
+ echo "Release branches? [$default_suggestion] \c"
+ read answer
+ [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
+ git config gitflow.prefix.release "$prefix"
+ fi
+
# Hotfix branches
- default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
- echo "Hotfix branches? [$default_suggestion] \c"
- read answer
- [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.hotfix "$prefix"
+ if ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
+ echo "Hotfix branches? [$default_suggestion] \c"
+ read answer
+ [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
+ git config gitflow.prefix.hotfix "$prefix"
+ fi
+
# Support branches
- default_suggestion=$(git config --get gitflow.prefix.support || echo support/)
- echo "Support branches? [$default_suggestion] \c"
- read answer
- [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.support "$prefix"
+ if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get gitflow.prefix.support || echo support/)
+ echo "Support branches? [$default_suggestion] \c"
+ read answer
+ [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
+ git config gitflow.prefix.support "$prefix"
+ fi
+
# Version tag prefix
- default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "")
- echo "Version tag prefix? [$default_suggestion] \c"
- read answer
- [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.versiontag "$prefix"
+ if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then
+ default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "")
+ echo "Version tag prefix? [$default_suggestion] \c"
+ read answer
+ [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
+ git config gitflow.prefix.versiontag "$prefix"
+ fi
+
# TODO: what to do with origin?
}
View
18 gitflow-common
@@ -49,12 +49,20 @@ gitflow_has_develop_configured() {
[ "$develop" != "" ] && gitflow_local_branch_exists "$develop"
}
+gitflow_has_prefixes_configured() {
+ git config --get gitflow.prefix.feature >/dev/null 2>&1 && \
+ git config --get gitflow.prefix.release >/dev/null 2>&1 && \
+ git config --get gitflow.prefix.hotfix >/dev/null 2>&1 && \
+ git config --get gitflow.prefix.support >/dev/null 2>&1 && \
+ git config --get gitflow.prefix.versiontag >/dev/null 2>&1
+}
+
gitflow_is_initialized() {
- gitflow_has_master_configured && \
- gitflow_has_develop_configured && \
- # they should be different
- [ "$(git config --get gitflow.branch.master)" != \
- "$(git config --get gitflow.branch.develop)" ]
+ gitflow_has_master_configured && \
+ gitflow_has_develop_configured && \
+ [ "$(git config --get gitflow.branch.master)" != \
+ "$(git config --get gitflow.branch.develop)" ] && \
+ gitflow_has_prefixes_configured
}
# get all available branches
Please sign in to comment.
Something went wrong with that request. Please try again.