blob: adb336df73fb5fd1b74a5b2bf35d170446151cad [file] [log] [blame]
Benedikt Böhm00ccea62010-01-26 12:39:36 +01001#
Vincent Driessen6c2d30b2010-01-26 22:18:36 +01002# git-flow -- A collection of Git extensions to provide high-level
3# repository operations for Vincent Driessen's branching model.
Benedikt Böhm00ccea62010-01-26 12:39:36 +01004#
5# Original blog post presenting this model is found at:
6# http://nvie.com/archives/323
7#
8# Feel free to contribute to this project at:
9# http://github.com/nvie/gitflow
10#
11# Copyright (c) 2010 by Vincent Driessen
12# Copyright (c) 2010 by Benedikt Böhm
13#
14
15usage() {
Vincent Driessen170dc742010-01-28 00:20:51 +010016 echo "usage: git flow support"
17 echo " git flow support start <version> [<base>]"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010018}
19
20parse_args() {
Benedikt Böhmb22a0762010-01-28 01:07:06 +080021 VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
Benedikt Böhm00ccea62010-01-26 12:39:36 +010022 VERSION="$1"
Benedikt Böhmb22a0762010-01-28 01:07:06 +080023 BASE="${2:-${VERSION_PREFIX}${VERSION}}"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010024 if [ "$VERSION" = "" ]; then
25 echo "Missing argument <version>."
26 usage
27 exit 1
28 fi
Benedikt Böhm96f44c02010-01-26 13:09:32 +010029 PREFIX=$(git config --get gitflow.prefix.support || echo support/)
30 BRANCH=$PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010031}
32
Vincent Driessen170dc742010-01-28 00:20:51 +010033cmd_default() {
34 # TODO: Refactor getting this prefix into a general function
35 PREFIX=$(git config --get gitflow.prefix.support || echo support/)
36 SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
37 if [ -z "$SUPPORT_BRANCHES" ]; then
38 warn "No support branches exist."
39 exit 0
40 fi
41 echo "$SUPPORT_BRANCHES" | sed "s?^$PREFIX??g"
42}
43
Benedikt Böhm00ccea62010-01-26 12:39:36 +010044cmd_help() {
45 usage
46 exit 0
47}
48
49cmd_start() {
50 parse_args "$@"
51
52 # sanity checks
53 gitflow_check_clean_working_tree
54
55 # create branch
56 git checkout -b $BRANCH $BASE
57
58 # publish branch
Benedikt Böhm350e7152010-01-26 13:05:05 +010059 git push $ORIGIN $BRANCH:refs/heads/$BRANCH
Benedikt Böhm4d222272010-01-26 14:46:56 +010060 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010061 git config branch.$BRANCH.remote $ORIGIN
Benedikt Böhm00ccea62010-01-26 12:39:36 +010062 git config branch.$BRANCH.merge refs/heads/$BRANCH
Vincent Driessena7d45272010-01-26 23:49:47 +010063 git checkout $BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010064
65 echo
66 echo "Summary of actions:"
67 echo "- A new remote branch '$BRANCH' was created, based on '$BASE'"
68 echo "- A new tracking branch '$BRANCH' was created"
69 echo "- You are now on branch '$BRANCH'"
70 echo
71}