2010-01-26 13:41:20 +00:00
|
|
|
#!/bin/sh
|
2010-01-21 00:36:44 +00:00
|
|
|
#
|
2010-01-26 21:18:36 +00:00
|
|
|
# git-flow -- A collection of Git extensions to provide high-level
|
|
|
|
# repository operations for Vincent Driessen's branching model.
|
2010-01-26 11:39:36 +00:00
|
|
|
#
|
2010-01-21 00:36:44 +00:00
|
|
|
# Original blog post presenting this model is found at:
|
|
|
|
# http://nvie.com/archives/323
|
2010-01-26 11:39:36 +00:00
|
|
|
#
|
2010-01-21 00:36:44 +00:00
|
|
|
# Feel free to contribute to this project at:
|
|
|
|
# http://github.com/nvie/gitflow
|
|
|
|
#
|
2010-04-04 14:10:17 +00:00
|
|
|
# Copyright 2010 Vincent Driessen. All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions and the following disclaimer.
|
|
|
|
#
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
|
|
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
|
|
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# The views and conclusions contained in the software and documentation are
|
|
|
|
# those of the authors and should not be interpreted as representing official
|
|
|
|
# policies, either expressed or implied, of Vincent Driessen.
|
2010-01-21 00:36:44 +00:00
|
|
|
#
|
2010-01-21 00:28:08 +00:00
|
|
|
|
2010-01-26 11:44:55 +00:00
|
|
|
# enable debug mode
|
|
|
|
if [ "$DEBUG" = "yes" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2010-01-26 11:59:27 +00:00
|
|
|
export GITFLOW_DIR=$(dirname "$0")
|
|
|
|
|
2010-01-26 11:39:36 +00:00
|
|
|
usage() {
|
2010-01-27 22:48:39 +00:00
|
|
|
echo "usage: git flow <subcommand>"
|
2010-01-26 11:39:36 +00:00
|
|
|
echo
|
2010-01-27 22:48:39 +00:00
|
|
|
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."
|
2010-01-27 23:13:26 +00:00
|
|
|
echo " version Shows version information."
|
2010-01-26 12:17:12 +00:00
|
|
|
echo
|
2010-01-27 22:48:39 +00:00
|
|
|
echo "Try 'git flow <subcommand> help' for details."
|
2010-01-26 11:39:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
2010-01-26 17:23:44 +00:00
|
|
|
if [ $# -lt 1 ]; then
|
2010-01-26 11:39:36 +00:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-02-05 18:53:45 +00:00
|
|
|
# load common functionality
|
|
|
|
. "$GITFLOW_DIR/gitflow-common"
|
|
|
|
|
2010-01-30 19:51:03 +00:00
|
|
|
# use the shFlags project to parse the command line arguments
|
2010-02-05 18:53:45 +00:00
|
|
|
. "$GITFLOW_DIR/gitflow-shFlags"
|
2010-02-02 22:53:21 +00:00
|
|
|
FLAGS_PARENT="git flow"
|
2010-01-30 19:51:03 +00:00
|
|
|
FLAGS "$@" || exit $?
|
|
|
|
eval set -- "${FLAGS_ARGV}"
|
|
|
|
|
2010-01-26 11:39:36 +00:00
|
|
|
# sanity checks
|
2010-01-27 22:48:39 +00:00
|
|
|
SUBCOMMAND="$1"; shift
|
2010-01-26 17:23:44 +00:00
|
|
|
|
2010-01-27 22:48:39 +00:00
|
|
|
if [ ! -e "$GITFLOW_DIR/git-flow-$SUBCOMMAND" ]; then
|
2010-01-26 11:39:36 +00:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# run command
|
2010-01-27 22:48:39 +00:00
|
|
|
. "$GITFLOW_DIR/git-flow-$SUBCOMMAND"
|
2010-02-02 22:53:21 +00:00
|
|
|
FLAGS_PARENT="git flow $SUBCOMMAND"
|
2010-01-26 11:39:36 +00:00
|
|
|
|
2010-02-01 14:51:43 +00:00
|
|
|
# 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
|
2010-02-15 22:23:14 +00:00
|
|
|
if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then
|
2010-02-04 10:49:47 +00:00
|
|
|
warn "Unknown subcommand: '$SUBACTION'"
|
2010-01-27 22:48:39 +00:00
|
|
|
usage
|
|
|
|
exit 1
|
2010-01-26 17:23:44 +00:00
|
|
|
fi
|
|
|
|
|
2010-01-27 22:48:39 +00:00
|
|
|
# run the specified action
|
|
|
|
cmd_$SUBACTION "$@"
|
2010-01-26 17:23:44 +00:00
|
|
|
}
|
|
|
|
|
2010-01-26 11:39:36 +00:00
|
|
|
main "$@"
|