Skip to content
This repository
tree: b554186c4c
Fetching contributors…

Cannot retrieve contributors at this time

executable file 88 lines (74 sloc) 2.211 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
#!/bin/sh
#
# git-flow -- A collection of Git extensions to provide high-level
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
# http://nvie.com/archives/323
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
# Copyright (c) 2010 by Vincent Driessen
# Copyright (c) 2010 by Benedikt Böhm
#

# enable debug mode
if [ "$DEBUG" = "yes" ]; then
set -x
fi

export GITFLOW_DIR=$(dirname "$0")

usage() {
echo "usage: git flow <subcommand>"
echo
echo "Available subcommands are:"
echo " init Initialize a new git repo with support for the branching model."
echo " feature Manage your feature branches."
echo " release Manage your release branches."
echo " hotfix Manage your hotfix branches."
echo " support Manage your support branches."
echo " version Shows version information."
echo
echo "Try 'git flow <subcommand> help' for details."
}

main() {
if [ $# -lt 1 ]; then
usage
exit 1
fi

# load common functionality
. "$GITFLOW_DIR/gitflow-common"

# use the shFlags project to parse the command line arguments
. "$GITFLOW_DIR/gitflow-shFlags"
FLAGS_PARENT="git flow"
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"

# sanity checks
SUBCOMMAND="$1"; shift

if [ ! -e "$GITFLOW_DIR/git-flow-$SUBCOMMAND" ]; then
usage
exit 1
fi

# run command
. "$GITFLOW_DIR/git-flow-$SUBCOMMAND"
FLAGS_PARENT="git flow $SUBCOMMAND"

# test if the first argument is a flag (i.e. starts with '-')
# in that case, we interpret this arg as a flag for the default
# command
SUBACTION="default"
if [ "$1" != "" ] && ! echo "$1" | grep -q "^-"; then
SUBACTION="$1"; shift
fi
if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then
warn "Unknown subcommand: '$SUBACTION'"
usage
exit 1
fi

# run the specified action
cmd_$SUBACTION "$@"
}

# helper functions for common reuse
max() { if [ "$1" -gt "$2" ]; then echo "$1"; else echo "$2"; fi; }

# convenience functions for checking whether flags have been set or not
flag() { eval FLAG=\$FLAGS_$1; [ $FLAG -eq $FLAGS_TRUE ]; }
noflag() { eval FLAG=\$FLAGS_$1; [ $FLAG -ne $FLAGS_TRUE ]; }

main "$@"
Something went wrong with that request. Please try again.