blob: 739ddfd707c38ff1f5fba39c8429a6a2fa5bd257 [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
Benedikt Böhm49dd62b2010-01-28 00:51:15 +010015VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
16PREFIX=$(git config --get gitflow.prefix.support || echo support/)
17
Benedikt Böhm00ccea62010-01-26 12:39:36 +010018usage() {
Vincent Driessen170dc742010-01-28 00:20:51 +010019 echo "usage: git flow support"
20 echo " git flow support start <version> [<base>]"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010021}
22
23parse_args() {
24 VERSION="$1"
Benedikt Böhmb22a0762010-01-28 01:07:06 +080025 BASE="${2:-${VERSION_PREFIX}${VERSION}}"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010026 if [ "$VERSION" = "" ]; then
27 echo "Missing argument <version>."
28 usage
29 exit 1
30 fi
Benedikt Böhm96f44c02010-01-26 13:09:32 +010031 BRANCH=$PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010032}
33
Vincent Driessen170dc742010-01-28 00:20:51 +010034cmd_default() {
Vincent Driessen170dc742010-01-28 00:20:51 +010035 SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
36 if [ -z "$SUPPORT_BRANCHES" ]; then
37 warn "No support branches exist."
38 exit 0
39 fi
40 echo "$SUPPORT_BRANCHES" | sed "s?^$PREFIX??g"
41}
42
Benedikt Böhm00ccea62010-01-26 12:39:36 +010043cmd_help() {
44 usage
45 exit 0
46}
47
48cmd_start() {
49 parse_args "$@"
50
51 # sanity checks
52 gitflow_check_clean_working_tree
53
54 # create branch
55 git checkout -b $BRANCH $BASE
56
57 # publish branch
Benedikt Böhm350e7152010-01-26 13:05:05 +010058 git push $ORIGIN $BRANCH:refs/heads/$BRANCH
Benedikt Böhm4d222272010-01-26 14:46:56 +010059 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010060 git config branch.$BRANCH.remote $ORIGIN
Benedikt Böhm00ccea62010-01-26 12:39:36 +010061 git config branch.$BRANCH.merge refs/heads/$BRANCH
Vincent Driessena7d45272010-01-26 23:49:47 +010062 git checkout $BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010063
64 echo
65 echo "Summary of actions:"
66 echo "- A new remote branch '$BRANCH' was created, based on '$BASE'"
67 echo "- A new tracking branch '$BRANCH' was created"
68 echo "- You are now on branch '$BRANCH'"
69 echo
70}