Commit 4f1cc330 authored by Vincent Driessen's avatar Vincent Driessen

Added functions for assuring branches are in place before doing the actual work.

- gitflow_require_local_branch()
- gitflow_require_remote_branch()
- gitflow_require_branch()
parent 7d0a4096
......@@ -12,7 +12,42 @@
# Copyright (c) 2010 by Vincent Driessen
#
# 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() {
echo "Working tree $(pwd) clean."
# 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
}
#!/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."
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