blob: fe7ce17735a3da2317ff5e3e54147335910c42d2 [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 Driessenb866b012010-01-28 01:01:53 +010016 echo "usage: git flow support [list]"
Vincent Driessen170dc742010-01-28 00:20:51 +010017 echo " git flow support start <version> [<base>]"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010018}
19
Vincent Driessenb866b012010-01-28 01:01:53 +010020setup() {
21 PREFIX=$(git config --get gitflow.prefix.support || echo support/)
22}
23
24cmd_default() {
25 cmd_list "$@"
26}
27
28cmd_list() {
29 SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
30 if [ -z "$SUPPORT_BRANCHES" ]; then
31 warn "No support branches exist."
32 exit 0
33 fi
34 echo "$SUPPORT_BRANCHES" | sed "s?^$PREFIX??g"
35}
36
37cmd_help() {
38 usage
39 exit 0
40}
41
Benedikt Böhm00ccea62010-01-26 12:39:36 +010042parse_args() {
Benedikt Böhmb22a0762010-01-28 01:07:06 +080043 VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
Benedikt Böhm00ccea62010-01-26 12:39:36 +010044 VERSION="$1"
Benedikt Böhmb22a0762010-01-28 01:07:06 +080045 BASE="${2:-${VERSION_PREFIX}${VERSION}}"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010046 if [ "$VERSION" = "" ]; then
47 echo "Missing argument <version>."
48 usage
49 exit 1
50 fi
Benedikt Böhm96f44c02010-01-26 13:09:32 +010051 PREFIX=$(git config --get gitflow.prefix.support || echo support/)
52 BRANCH=$PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010053}
54
Benedikt Böhm00ccea62010-01-26 12:39:36 +010055cmd_start() {
56 parse_args "$@"
57
58 # sanity checks
59 gitflow_check_clean_working_tree
60
61 # create branch
62 git checkout -b $BRANCH $BASE
63
64 # publish branch
Benedikt Böhm350e7152010-01-26 13:05:05 +010065 git push $ORIGIN $BRANCH:refs/heads/$BRANCH
Benedikt Böhm4d222272010-01-26 14:46:56 +010066 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010067 git config branch.$BRANCH.remote $ORIGIN
Benedikt Böhm00ccea62010-01-26 12:39:36 +010068 git config branch.$BRANCH.merge refs/heads/$BRANCH
Vincent Driessena7d45272010-01-26 23:49:47 +010069 git checkout $BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010070
71 echo
72 echo "Summary of actions:"
73 echo "- A new remote branch '$BRANCH' was created, based on '$BASE'"
74 echo "- A new tracking branch '$BRANCH' was created"
75 echo "- You are now on branch '$BRANCH'"
76 echo
77}