Commit cbe180f5 authored by Peter van der Does's avatar Peter van der Does Committed by Vincent Driessen

Add directory setup to the git flow init process

git flow will fail when the directories are not setup in the git config.
Signed-off-by: 's avatarPeter van der Does <peter@avirtualhome.com>
Signed-off-by: 's avatarVincent Driessen <vincent@3rdcloud.com>
parent 07dacd52
...@@ -222,7 +222,7 @@ cmd_default() { ...@@ -222,7 +222,7 @@ cmd_default() {
git checkout -q "$develop_branch" git checkout -q "$develop_branch"
fi fi
# finally, ask the user for naming conventions (branch and tag prefixes) # Ask the user for naming conventions (branch and tag prefixes )
if flag force || \ if flag force || \
! git config --get gitflow.prefix.feature >/dev/null 2>&1 || ! 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.release >/dev/null 2>&1 ||
...@@ -303,6 +303,47 @@ cmd_default() { ...@@ -303,6 +303,47 @@ cmd_default() {
git config gitflow.prefix.versiontag "$prefix" git config gitflow.prefix.versiontag "$prefix"
fi fi
# Ask the user for gitflow configuration directory (main and hooks )
if flag force || \
! git config --get gitflow.dir.main >/dev/null 2>&1 ||
! git config --get gitflow.dir.hooks >/dev/null 2>&1; then
echo
echo "Where is the gitflow directory located?"
fi
local dir
# Main directory
if ! git config --get gitflow.dir.main >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.dir.main || echo .gitflow/)
printf "gitflow configuration directory? [$default_suggestion] "
if noflag defaults; then
read answer
else
printf "\n"
fi
[ "$answer" = "-" ] && dir= || dir=${answer:-$default_suggestion}
if [ ! -d "$dir" ] ; then
mkdir "$dir" >/dev/null 2>&1 || die "Can not create directory ${dir}"
fi
git config gitflow.dir.main "$dir"
fi
local subdir
# Hooks directory
if ! git config --get gitflow.dir.hooks >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.dir.hooks || echo hooks/)
printf "gitflow hooks directory? [$default_suggestion] "
if noflag defaults; then
read answer
else
printf "\n"
fi
[ "$answer" = "-" ] && subdir= || subdir=${answer:-$default_suggestion}
if [ ! -d "$dir""$subdir" ] ; then
mkdir -p "$dir""$subdir" >/dev/null 2>&1 || die "Can not create directory ${dir}${subdir}"
fi
git config gitflow.dir.hooks "$subdir"
fi
# TODO: what to do with origin? # TODO: what to do with origin?
} }
......
...@@ -175,12 +175,18 @@ gitflow_has_prefixes_configured() { ...@@ -175,12 +175,18 @@ gitflow_has_prefixes_configured() {
git config --get gitflow.prefix.versiontag >/dev/null 2>&1 git config --get gitflow.prefix.versiontag >/dev/null 2>&1
} }
gitflow_has_dirs_configured() {
git config --get gitflow.dir.main >/dev/null 2>&1 && \
git config --get gitflow.dir.hooks >/dev/null 2>&1
}
gitflow_is_initialized() { gitflow_is_initialized() {
gitflow_has_master_configured && \ gitflow_has_master_configured && \
gitflow_has_develop_configured && \ gitflow_has_develop_configured && \
[ "$(git config --get gitflow.branch.master)" != \ [ "$(git config --get gitflow.branch.master)" != \
"$(git config --get gitflow.branch.develop)" ] && \ "$(git config --get gitflow.branch.develop)" ] && \
gitflow_has_prefixes_configured gitflow_has_prefixes_configured && \
gitflow_has_dirs_configured
} }
# loading settings that can be overridden using git config # loading settings that can be overridden using git config
...@@ -189,6 +195,7 @@ gitflow_load_settings() { ...@@ -189,6 +195,7 @@ gitflow_load_settings() {
export MASTER_BRANCH=$(git config --get gitflow.branch.master) export MASTER_BRANCH=$(git config --get gitflow.branch.master)
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop) export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop)
export ORIGIN=$(git config --get gitflow.origin || echo origin) export ORIGIN=$(git config --get gitflow.origin || echo origin)
export GITFLOW_DIR_HOOKS=$(git config --get gitflow.dir.main)$(git config --get gitflow.dir.hooks)
} }
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment