Rewrite the way git-flow initialized its variables in git-flow and assumed
existence of a valid git repo. Instead, functions gitflow_load_settings() and gitflow_require_git_repo() have been added that can be called in each submodule that requires such. Specifically, git-flow init does NOT use this.
This commit is contained in:
parent
21c7aa9c8b
commit
d72e4aceed
6 changed files with 23 additions and 9 deletions
9
git-flow
9
git-flow
|
@ -19,11 +19,6 @@ if [ "$DEBUG" = "yes" ]; then
|
|||
fi
|
||||
|
||||
export GITFLOW_DIR=$(dirname "$0")
|
||||
export GIT_DIR=$(git rev-parse --git-dir)
|
||||
export MASTER_BRANCH=$(git config --get gitflow.branch.master || echo master)
|
||||
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop || echo develop)
|
||||
export ORIGIN=$(git config --get gitflow.origin || echo origin)
|
||||
export README=$(git config --get gitflow.readme || echo README)
|
||||
|
||||
usage() {
|
||||
echo "usage: git flow <subcommand>"
|
||||
|
@ -62,10 +57,6 @@ main() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if ! git rev-parse --git-dir >/dev/null; then
|
||||
die "Not a git repository"
|
||||
fi
|
||||
|
||||
# run command
|
||||
. "$GITFLOW_DIR/git-flow-$SUBCOMMAND"
|
||||
FLAGS_PARENT="git flow $SUBCOMMAND"
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# Copyright (c) 2010 by Benedikt Böhm
|
||||
#
|
||||
|
||||
gitflow_require_git_repo
|
||||
gitflow_load_settings
|
||||
PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)
|
||||
|
||||
usage() {
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# Copyright (c) 2010 by Benedikt Böhm
|
||||
#
|
||||
|
||||
gitflow_require_git_repo
|
||||
gitflow_load_settings
|
||||
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
|
||||
PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# Copyright (c) 2010 by Benedikt Böhm
|
||||
#
|
||||
|
||||
gitflow_require_git_repo
|
||||
gitflow_load_settings
|
||||
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
|
||||
PREFIX=$(git config --get gitflow.prefix.release || echo release/)
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# Copyright (c) 2010 by Benedikt Böhm
|
||||
#
|
||||
|
||||
gitflow_require_git_repo
|
||||
gitflow_load_settings
|
||||
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
|
||||
PREFIX=$(git config --get gitflow.prefix.support || echo support/)
|
||||
|
||||
|
|
|
@ -44,6 +44,15 @@ gitflow_remote_branches() { git branch -r | sed 's/^[* ] //'; }
|
|||
gitflow_all_branches() { gitflow_local_branches; gitflow_remote_branches; }
|
||||
gitflow_all_tags() { git tag; }
|
||||
|
||||
# loading settings that can be overridden using git config
|
||||
gitflow_load_settings() {
|
||||
export GIT_DIR=$(git rev-parse --git-dir >/dev/null 2>&1)
|
||||
export MASTER_BRANCH=$(git config --get gitflow.branch.master || echo master)
|
||||
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop || echo develop)
|
||||
export ORIGIN=$(git config --get gitflow.origin || echo origin)
|
||||
export README=$(git config --get gitflow.readme || echo README)
|
||||
}
|
||||
|
||||
#
|
||||
# resolve_nameprefix
|
||||
#
|
||||
|
@ -107,6 +116,12 @@ gitflow_test_clean_working_tree() {
|
|||
fi
|
||||
}
|
||||
|
||||
gitflow_require_git_repo() {
|
||||
if ! git rev-parse --git-dir >/dev/null 2>&1; then
|
||||
die "Not a git repository"
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_clean_working_tree() {
|
||||
gitflow_test_clean_working_tree
|
||||
local result=$?
|
||||
|
|
Loading…
Reference in a new issue