Added functions for assuring branches are in place before doing the actual work.
- gitflow_require_local_branch() - gitflow_require_remote_branch() - gitflow_require_branch()
This commit is contained in:
parent
7d0a4096f7
commit
4f1cc33044
2 changed files with 46 additions and 2 deletions
|
@ -12,7 +12,42 @@
|
|||
# Copyright (c) 2010 by Vincent Driessen
|
||||
#
|
||||
|
||||
gitflow_check_clean_working_tree() {
|
||||
echo "Working tree $(pwd) clean."
|
||||
# Get the git dir
|
||||
GIT_DIR=$(git rev-parse --git-dir)
|
||||
|
||||
# Get all available branches
|
||||
LOCAL_BRANCHES=$(cd "$GIT_DIR/refs/heads"; find * -type f)
|
||||
REMOTE_BRANCHES=$(cd "$GIT_DIR/refs/remotes"; find * -type f)
|
||||
ALL_BRANCHES="$LOCAL_BRANCHES\n$REMOTE_BRANCHES"
|
||||
|
||||
die() {
|
||||
echo "$@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
gitflow_check_clean_working_tree() {
|
||||
# TODO: Implement this
|
||||
echo "TODO"
|
||||
}
|
||||
|
||||
gitflow_require_local_branch() {
|
||||
echo "$LOCAL_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
die "Local branch '$1' does not exist and is required."
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_remote_branch() {
|
||||
echo "$REMOTE_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
die "Remote branch '$1' does not exist and is required."
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_branch() {
|
||||
echo "$ALL_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
die "Branch '$1' does not exist and is required."
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
9
test-sh-setup
Executable file
9
test-sh-setup
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
. gitflow-sh-setup
|
||||
|
||||
gitflow_require_branch 'master'
|
||||
gitflow_require_branch 'develop'
|
||||
gitflow_require_branch 'origin/develop'
|
||||
gitflow_require_branch 'origin/master'
|
||||
|
||||
echo "All OK."
|
Loading…
Reference in a new issue