Benedikt Böhm | e2fa491 | 2010-01-26 14:41:20 +0100 | [diff] [blame] | 1 | #!/bin/sh |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 2 | # |
Vincent Driessen | 6c2d30b | 2010-01-26 22:18:36 +0100 | [diff] [blame] | 3 | # git-flow -- A collection of Git extensions to provide high-level |
| 4 | # repository operations for Vincent Driessen's branching model. |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 5 | # |
| 6 | # Original blog post presenting this model is found at: |
Vincent Driessen | ddb350b | 2010-07-09 09:42:09 +0200 | [diff] [blame] | 7 | # http://nvie.com/git-model |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 8 | # |
| 9 | # Feel free to contribute to this project at: |
| 10 | # http://github.com/nvie/gitflow |
| 11 | # |
Vincent Driessen | d72acba | 2010-04-04 16:10:17 +0200 | [diff] [blame] | 12 | # Copyright 2010 Vincent Driessen. All rights reserved. |
| 13 | # |
| 14 | # Redistribution and use in source and binary forms, with or without |
| 15 | # modification, are permitted provided that the following conditions are met: |
| 16 | # |
| 17 | # 1. Redistributions of source code must retain the above copyright notice, |
| 18 | # this list of conditions and the following disclaimer. |
| 19 | # |
| 20 | # 2. Redistributions in binary form must reproduce the above copyright |
| 21 | # notice, this list of conditions and the following disclaimer in the |
| 22 | # documentation and/or other materials provided with the distribution. |
| 23 | # |
| 24 | # THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR |
| 25 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 26 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 27 | # EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 28 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 29 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 30 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 31 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 32 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 33 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | # |
| 35 | # The views and conclusions contained in the software and documentation are |
| 36 | # those of the authors and should not be interpreted as representing official |
| 37 | # policies, either expressed or implied, of Vincent Driessen. |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 38 | # |
| 39 | |
Benedikt Böhm | e5eaff9 | 2010-01-26 12:44:55 +0100 | [diff] [blame] | 40 | # enable debug mode |
| 41 | if [ "$DEBUG" = "yes" ]; then |
| 42 | set -x |
| 43 | fi |
| 44 | |
Benedikt Böhm | 4a864fb | 2010-01-26 12:59:27 +0100 | [diff] [blame] | 45 | export GITFLOW_DIR=$(dirname "$0") |
Benedikt Böhm | 4a864fb | 2010-01-26 12:59:27 +0100 | [diff] [blame] | 46 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 47 | usage() { |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 48 | echo "usage: git flow <subcommand>" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 49 | echo |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 50 | echo "Available subcommands are:" |
| 51 | echo " init Initialize a new git repo with support for the branching model." |
| 52 | echo " feature Manage your feature branches." |
| 53 | echo " release Manage your release branches." |
| 54 | echo " hotfix Manage your hotfix branches." |
| 55 | echo " support Manage your support branches." |
Vincent Driessen | 3625f39 | 2010-01-28 00:13:26 +0100 | [diff] [blame] | 56 | echo " version Shows version information." |
Benedikt Böhm | 7d703a8 | 2010-01-26 13:17:12 +0100 | [diff] [blame] | 57 | echo |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 58 | echo "Try 'git flow <subcommand> help' for details." |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | main() { |
Benedikt Böhm | 427c5db | 2010-01-26 18:23:44 +0100 | [diff] [blame] | 62 | if [ $# -lt 1 ]; then |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 63 | usage |
| 64 | exit 1 |
| 65 | fi |
| 66 | |
Vincent Driessen | c3607ac | 2010-02-05 19:53:45 +0100 | [diff] [blame] | 67 | # load common functionality |
| 68 | . "$GITFLOW_DIR/gitflow-common" |
| 69 | |
Vincent Driessen | ea58d0f | 2010-01-30 20:51:03 +0100 | [diff] [blame] | 70 | # use the shFlags project to parse the command line arguments |
Vincent Driessen | c3607ac | 2010-02-05 19:53:45 +0100 | [diff] [blame] | 71 | . "$GITFLOW_DIR/gitflow-shFlags" |
Vincent Driessen | 4417492 | 2010-02-02 23:53:21 +0100 | [diff] [blame] | 72 | FLAGS_PARENT="git flow" |
Vincent Driessen | ea58d0f | 2010-01-30 20:51:03 +0100 | [diff] [blame] | 73 | FLAGS "$@" || exit $? |
| 74 | eval set -- "${FLAGS_ARGV}" |
| 75 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 76 | # sanity checks |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 77 | SUBCOMMAND="$1"; shift |
Benedikt Böhm | 427c5db | 2010-01-26 18:23:44 +0100 | [diff] [blame] | 78 | |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 79 | if [ ! -e "$GITFLOW_DIR/git-flow-$SUBCOMMAND" ]; then |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 80 | usage |
| 81 | exit 1 |
| 82 | fi |
| 83 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 84 | # run command |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 85 | . "$GITFLOW_DIR/git-flow-$SUBCOMMAND" |
Vincent Driessen | 4417492 | 2010-02-02 23:53:21 +0100 | [diff] [blame] | 86 | FLAGS_PARENT="git flow $SUBCOMMAND" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 87 | |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 88 | # test if the first argument is a flag (i.e. starts with '-') |
| 89 | # in that case, we interpret this arg as a flag for the default |
| 90 | # command |
| 91 | SUBACTION="default" |
| 92 | if [ "$1" != "" ] && ! echo "$1" | grep -q "^-"; then |
| 93 | SUBACTION="$1"; shift |
| 94 | fi |
Vincent Driessen | 283b0f7 | 2010-02-15 23:23:14 +0100 | [diff] [blame] | 95 | if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then |
Vincent Driessen | 9277024 | 2010-02-04 11:49:47 +0100 | [diff] [blame] | 96 | warn "Unknown subcommand: '$SUBACTION'" |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 97 | usage |
| 98 | exit 1 |
Benedikt Böhm | 427c5db | 2010-01-26 18:23:44 +0100 | [diff] [blame] | 99 | fi |
| 100 | |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 101 | # run the specified action |
| 102 | cmd_$SUBACTION "$@" |
Benedikt Böhm | 427c5db | 2010-01-26 18:23:44 +0100 | [diff] [blame] | 103 | } |
| 104 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 105 | main "$@" |