Commit e034e4a2 authored by Vincent Driessen's avatar Vincent Driessen

Only have network connectivity when explicitly asked for feature branches....

Only have network connectivity when explicitly asked for feature branches. This action is so common that it should be quick (very git-ish).

For hotfix and release branches, forgetting to update would be an unsafe thing to do, so we leave the fetch in there by default.
parent 48386441
......@@ -13,6 +13,7 @@
#
PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)
FLAG_FETCH=0
usage() {
echo "usage: git flow feature [list]"
......@@ -55,6 +56,8 @@ cmd_help() {
}
parse_args() {
# TODO: When we have a nice structured way of parsing flags with getopt,
# implement the --fetch flag, to set FLAG_FETCH=1
NAME="$1"
BASE="${2:-$DEVELOP_BRANCH}"
if [ "$NAME" = "" ]; then
......@@ -71,11 +74,14 @@ cmd_start() {
# sanity checks
gitflow_require_clean_working_tree
gitflow_require_branch_absent $BRANCH
if [ "$BASE" = "$DEVELOP_BRANCH" ]; then
# update the local repo with remote changes, if asked
if [ $FLAG_FETCH -eq 1 ]; then
git fetch -q $ORIGIN $DEVELOP_BRANCH
gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
fi
gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
# create branch
git checkout -b $BRANCH $BASE
......@@ -96,7 +102,12 @@ cmd_finish() {
# sanity checks
gitflow_require_clean_working_tree
gitflow_require_branch $BRANCH
git fetch -q $ORIGIN
# update local repo with remote changes first, if asked
if [ $FLAG_FETCH -eq 1 ]; then
git fetch -q $ORIGIN $BRANCH
fi
if has $ORIGIN/$BRANCH $REMOTE_BRANCHES; then
gitflow_require_branches_equal $BRANCH $ORIGIN/$BRANCH
fi
......
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