Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 134 lines (114 sloc) 3.068 kB
00ccea6 @hollow refactor the whole thing
hollow authored
1 #
6c2d30b @nvie Structurally replace gitflow by git-flow, as a true git extension.
authored
2 # git-flow -- A collection of Git extensions to provide high-level
3 # repository operations for Vincent Driessen's branching model.
00ccea6 @hollow refactor the whole thing
hollow authored
4 #
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
49dd62b @hollow refactor git config calls to global variables
hollow authored
15 VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
16 PREFIX=$(git config --get gitflow.prefix.support || echo support/)
2acfffd @nvie Make the 'to fetch or not to fetch' flag explicit in the other comman…
authored
17 FLAG_FETCH=1
49dd62b @hollow refactor git config calls to global variables
hollow authored
18
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
19 warn "note: The support subcommand is still very EXPERIMENTAL!"
20 warn "note: DO NOT use it in a production situation."
21
00ccea6 @hollow refactor the whole thing
hollow authored
22 usage() {
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
23 echo "usage: git flow support [list] [-v]"
170dc74 @nvie Refactored the feature, release and support subcommands, too.
authored
24 echo " git flow support start <version> [<base>]"
00ccea6 @hollow refactor the whole thing
hollow authored
25 }
26
170dc74 @nvie Refactored the feature, release and support subcommands, too.
authored
27 cmd_default() {
b866b01 @nvie Give all subcommands an optional setup() function that will be called…
authored
28 cmd_list "$@"
00ccea6 @hollow refactor the whole thing
hollow authored
29 }
30
b866b01 @nvie Give all subcommands an optional setup() function that will be called…
authored
31 cmd_list() {
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
32 DEFINE_boolean verbose false 'verbose (more) output' v
33 parse_args "$@"
34
170dc74 @nvie Refactored the feature, release and support subcommands, too.
authored
35 SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
36 if [ -z "$SUPPORT_BRANCHES" ]; then
37 warn "No support branches exist."
38 exit 0
39 fi
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
40
41 CURRENT_BRANCH=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
42 SHORT_NAMES=$(echo "$SUPPORT_BRANCHES" | sed "s?^$PREFIX??g")
43 # determine column width first
44 width=0
45 for branch in $SHORT_NAMES; do
46 len=$(($(echo "$branch" | wc -c) - 1))
47 width=$(max $width $len)
48 done
49 width=$(($width + 3))
50
51 for branch in $SHORT_NAMES; do
52 fullname="$PREFIX$branch"
53 base=$(git merge-base "$fullname" "$MASTER_BRANCH")
54 master_sha=$(git rev-parse "$MASTER_BRANCH")
55 branch_sha=$(git rev-parse "$fullname")
56 if [ "$fullname" = "$CURRENT_BRANCH" ]; then
57 printf "* "
58 else
59 printf " "
60 fi
61 if flag verbose; then
62 printf "%-${width}s" "$branch"
63 if [ "$branch_sha" = "$master_sha" ]; then
64 printf "(no commits yet)"
65 else
66 tagname=$(git name-rev --tags --no-undefined --name-only $base)
67 if [ "$tagname" != "" ]; then
68 nicename="$tagname"
69 else
70 nicename="$(git rev-parse --short $base)"
71 fi
72 printf "(based on $nicename)"
73 fi
74 else
75 printf "%s" "$branch"
76 fi
77 echo
78 done
170dc74 @nvie Refactored the feature, release and support subcommands, too.
authored
79 }
80
00ccea6 @hollow refactor the whole thing
hollow authored
81 cmd_help() {
82 usage
83 exit 0
84 }
85
b866b01 @nvie Give all subcommands an optional setup() function that will be called…
authored
86 parse_args() {
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
87 # parse options
88 FLAGS "$@" || exit $?
89 eval set -- "${FLAGS_ARGV}"
90
91 # read arguments into global variables
b866b01 @nvie Give all subcommands an optional setup() function that will be called…
authored
92 VERSION="$1"
93 BASE="${2:-${VERSION_PREFIX}${VERSION}}"
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
94 BRANCH=$PREFIX$VERSION
95 }
96
97 require_version_arg() {
b866b01 @nvie Give all subcommands an optional setup() function that will be called…
authored
98 if [ "$VERSION" = "" ]; then
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
99 warn "Missing argument <version>"
b866b01 @nvie Give all subcommands an optional setup() function that will be called…
authored
100 usage
101 exit 1
102 fi
103 }
104
00ccea6 @hollow refactor the whole thing
hollow authored
105 cmd_start() {
106 parse_args "$@"
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
107 require_version_arg
00ccea6 @hollow refactor the whole thing
hollow authored
108
109 # sanity checks
4838644 @nvie Replace gitflow_check_ prefixes by gitflow_require_ prefixes, for con…
authored
110 gitflow_require_clean_working_tree
00ccea6 @hollow refactor the whole thing
hollow authored
111
2acfffd @nvie Make the 'to fetch or not to fetch' flag explicit in the other comman…
authored
112 # fetch remote changes
113 if [ $FLAG_FETCH -eq 1 ]; then
114 git fetch -q $ORIGIN $BASE
115 fi
116
00ccea6 @hollow refactor the whole thing
hollow authored
117 # create branch
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
118 git checkout -b "$BRANCH" "$BASE"
00ccea6 @hollow refactor the whole thing
hollow authored
119
120 # publish branch
3c337fb @nvie Added -v (--verbose) flags to list subaction of all subcommands.
authored
121 #git push $ORIGIN $BRANCH:refs/heads/$BRANCH
2acfffd @nvie Make the 'to fetch or not to fetch' flag explicit in the other comman…
authored
122
350e715 @hollow make origin configurable
hollow authored
123 git config branch.$BRANCH.remote $ORIGIN
00ccea6 @hollow refactor the whole thing
hollow authored
124 git config branch.$BRANCH.merge refs/heads/$BRANCH
a7d4527 @nvie Don't assume git aliases.
authored
125 git checkout $BRANCH
00ccea6 @hollow refactor the whole thing
hollow authored
126
127 echo
128 echo "Summary of actions:"
129 echo "- A new remote branch '$BRANCH' was created, based on '$BASE'"
130 echo "- A new tracking branch '$BRANCH' was created"
131 echo "- You are now on branch '$BRANCH'"
132 echo
133 }
Something went wrong with that request. Please try again.