Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
When -d flag, the defaults are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
petervanderdoes committed Feb 28, 2019
1 parent fe0f33a commit 2a86e10
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
# Changelog

#### 1.12.1-dev1
* Prepare for next release
[Peter van der Does][petervanderdoes]
* When using the `-d` flag during `init` the defaults are empty

#### 1.12.0
[Peter van der Does][petervanderdoes]
Expand Down
36 changes: 30 additions & 6 deletions git-flow-init
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ file= use given config file

# Feature branches
if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then
default_suggestion=$(echo $FLAGS_feature || git config --get gitflow.prefix.feature || echo feature/)
if [ "$FLAGS_feature" != "" ]; then
default_suggestion=$(echo $FLAGS_feature)
else
default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/)
fi
printf "Feature branches? [$default_suggestion] "
if noflag defaults; then
read answer
Expand All @@ -319,7 +323,11 @@ file= use given config file

# Bugfix branches
if ! git config --get gitflow.prefix.bugfix >/dev/null 2>&1 || flag force; then
default_suggestion=$(echo $FLAGS_bugfix || git config --get gitflow.prefix.bugfix || echo bugfix/)
if [ "$FLAGS_bugfix" != "" ]; then
default_suggestion=$(echo $FLAGS_bugfix)
else
default_suggestion=$(git config --get gitflow.prefix.bugfix || echo bugfix/)
fi
printf "Bugfix branches? [$default_suggestion] "
if noflag defaults; then
read answer
Expand All @@ -332,7 +340,11 @@ file= use given config file

# Release branches
if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then
default_suggestion=$(echo $FLAGS_release || git config --get gitflow.prefix.release || echo release/)
if [ "$FLAGS_release" != "" ]; then
default_suggestion=$(echo $FLAGS_release)
else
default_suggestion=$(git config --get gitflow.prefix.release || echo release/)
fi
printf "Release branches? [$default_suggestion] "
if noflag defaults; then
read answer
Expand All @@ -345,7 +357,11 @@ file= use given config file

# Hotfix branches
if ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || flag force; then
default_suggestion=$(echo $FLAGS_hotfix || git config --get gitflow.prefix.hotfix || echo hotfix/)
if [ "$FLAGS_hotfix" != "" ]; then
default_suggestion=$(echo $FLAGS_hotfix)
else
default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
fi
printf "Hotfix branches? [$default_suggestion] "
if noflag defaults; then
read answer
Expand All @@ -358,7 +374,11 @@ file= use given config file

# Support branches
if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then
default_suggestion=$(echo $FLAGS_support || git config --get gitflow.prefix.support || echo support/)
if [ "$FLAGS_support" != "" ]; then
default_suggestion=$(echo $FLAGS_support

This comment has been minimized.

Copy link
@Tiscs

Tiscs Mar 2, 2019

Contributor

Unexpected EOF while looking for matching `)'

This comment has been minimized.

Copy link
@petervanderdoes

petervanderdoes Mar 2, 2019

Author Owner

Thank you, fixed in 1.12.2

else
default_suggestion=$(git config --get gitflow.prefix.support || echo support/)
fi
printf "Support branches? [$default_suggestion] "
if noflag defaults; then
read answer
Expand All @@ -371,7 +391,11 @@ file= use given config file
# Version tag prefix
if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then
default_suggestion=$(echo $FLAGS_tag || git config --get gitflow.prefix.versiontag || echo "")
if [ "$FLAGS_tag" != "" ]; then
default_suggestion=$(echo $FLAGS_tag)
else
default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "")
fi
printf "Version tag prefix? [$default_suggestion] "
if noflag defaults; then
read answer
Expand Down

2 comments on commit 2a86e10

@Tiscs
Copy link
Contributor

@Tiscs Tiscs commented on 2a86e10 Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petervanderdoes
I'm so sorry about this, I created a PR #342 without detailed validation;
I fixed it in my branch, by set default value for options. I found this commit when creating new PR #404.

# line: 93
	DEFINE_string 'feature' "feature/" 'feature branches' p
	DEFINE_string 'bugfix' "bugfix/" 'bugfix branches' b
	DEFINE_string 'release' "release/" 'release branches' r
	DEFINE_string 'hotfix' "hotfix/" 'hotfix branches' x
	DEFINE_string 'support' "support/" 'support branches' s
	DEFINE_string 'tag' "" 'version tag prefix' t

@petervanderdoes
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do this, the default value would always be used even if there is a config somewhere stating a different name.

Please sign in to comment.