Skip to content
This repository
Newer
Older
100644 182 lines (163 sloc) 5.135 kb
00ccea60 » hollow
2010-01-26 refactor the whole thing
1 #
6c2d30bb »
2010-01-26 Structurally replace gitflow by git-flow, as a true git extension.
2 # git-flow -- A collection of Git extensions to provide high-level
3 # repository operations for Vincent Driessen's branching model.
00ccea60 » hollow
2010-01-26 refactor the whole thing
4 #
5 # Original blog post presenting this model is found at:
ddb350b3 »
2010-07-09 Change the URL of the original blog post.
6 # http://nvie.com/git-model
00ccea60 » hollow
2010-01-26 refactor the whole thing
7 #
8 # Feel free to contribute to this project at:
9 # http://github.com/nvie/gitflow
10 #
d72acbaf »
2010-04-04 Added inline license terms to all source files.
11 # Copyright 2010 Vincent Driessen. All rights reserved.
12 #
13 # Redistribution and use in source and binary forms, with or without
14 # modification, are permitted provided that the following conditions are met:
15 #
16 # 1. Redistributions of source code must retain the above copyright notice,
17 # this list of conditions and the following disclaimer.
18 #
19 # 2. Redistributions in binary form must reproduce the above copyright
20 # notice, this list of conditions and the following disclaimer in the
21 # documentation and/or other materials provided with the distribution.
22 #
23 # THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
26 # EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #
34 # The views and conclusions contained in the software and documentation are
35 # those of the authors and should not be interpreted as representing official
36 # policies, either expressed or implied, of Vincent Driessen.
00ccea60 » hollow
2010-01-26 refactor the whole thing
37 #
38
7832d6ef »
2010-02-21 Better naming of common functions categorizing them into common,
39 require_git_repo
40 require_gitflow_initialized
d72e4ace »
2010-02-16 Rewrite the way git-flow initialized its variables in git-flow and as…
41 gitflow_load_settings
ff275fa6 » nowells
2010-09-22 Changed versiontag prefix to allow addition of dynamic data (i.e. date)
42 VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
c1598bf2 »
2010-02-20 Added function gitflow_require_initialized(), to assert that the gitflow
43 PREFIX=$(git config --get gitflow.prefix.support)
49dd62b7 » hollow
2010-01-28 refactor git config calls to global variables
44
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
45 warn "note: The support subcommand is still very EXPERIMENTAL!"
46 warn "note: DO NOT use it in a production situation."
47
00ccea60 » hollow
2010-01-26 refactor the whole thing
48 usage() {
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
49 echo "usage: git flow support [list] [-v]"
a2e41163 »
2010-02-24 Document all available flags in all of the subcommand synopsis texts.
50 echo " git flow support start [-F] <version> <base>"
00ccea60 » hollow
2010-01-26 refactor the whole thing
51 }
52
170dc747 »
2010-01-28 Refactored the feature, release and support subcommands, too.
53 cmd_default() {
b866b01b »
2010-01-28 Give all subcommands an optional setup() function that will be called…
54 cmd_list "$@"
00ccea60 » hollow
2010-01-26 refactor the whole thing
55 }
56
b866b01b »
2010-01-28 Give all subcommands an optional setup() function that will be called…
57 cmd_list() {
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
58 DEFINE_boolean verbose false 'verbose (more) output' v
59 parse_args "$@"
60
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
61 local support_branches
62 local current_branch
63 local short_names
7832d6ef »
2010-02-21 Better naming of common functions categorizing them into common,
64 support_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
27592dd7 »
2010-02-06 Tidy up:
65 if [ -z "$support_branches" ]; then
170dc747 »
2010-01-28 Refactored the feature, release and support subcommands, too.
66 warn "No support branches exist."
b681b452 » Zoramite
2010-06-26 Adding extra instructions when running the list option without any co…
67 warn ""
68 warn "You can start a new support branch:"
69 warn ""
70 warn " git flow support start <name> <base>"
4de01f25 » Zoramite
2010-06-26 Adding an extra line to the output for extra spacing.
71 warn ""
170dc747 »
2010-01-28 Refactored the feature, release and support subcommands, too.
72 exit 0
73 fi
cf3da5a7 » adamgibbins
2010-08-22 Fixed incorrect color flag
74 current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
68845235 »
2010-02-10 Use space (' ') instead of '?' as a pattern terminator.
75 short_names=$(echo "$support_branches" | sed "s ^$PREFIX g")
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
76
77 # determine column width first
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
78 local width=0
79 local branch
27592dd7 »
2010-02-06 Tidy up:
80 for branch in $short_names; do
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
81 local len=${#branch}
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
82 width=$(max $width $len)
83 done
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
84 width=$(($width+3))
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
85
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
86 local branch
27592dd7 »
2010-02-06 Tidy up:
87 for branch in $short_names; do
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
88 local fullname=$PREFIX$branch
89 local base=$(git merge-base "$fullname" "$MASTER_BRANCH")
90 local master_sha=$(git rev-parse "$MASTER_BRANCH")
91 local branch_sha=$(git rev-parse "$fullname")
27592dd7 »
2010-02-06 Tidy up:
92 if [ "$fullname" = "$current_branch" ]; then
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
93 printf "* "
94 else
95 printf " "
96 fi
97 if flag verbose; then
98 printf "%-${width}s" "$branch"
99 if [ "$branch_sha" = "$master_sha" ]; then
100 printf "(no commits yet)"
101 else
f46e2903 »
2010-02-15 Replaced all 'typeset' and 'typeset -i' calls by 'local', as adviced on:
102 local tagname=$(git name-rev --tags --no-undefined --name-only "$base")
103 local nicename
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
104 if [ "$tagname" != "" ]; then
c5fcc01a »
2010-02-10 Do not quote variable assignments.
105 nicename=$tagname
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
106 else
a4dd223d »
2010-02-10 Quote all variables in function/program arguments.
107 nicename=$(git rev-parse --short "$base")
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
108 fi
109 printf "(based on $nicename)"
110 fi
111 else
112 printf "%s" "$branch"
113 fi
114 echo
115 done
170dc747 »
2010-01-28 Refactored the feature, release and support subcommands, too.
116 }
117
00ccea60 » hollow
2010-01-26 refactor the whole thing
118 cmd_help() {
119 usage
120 exit 0
121 }
122
b866b01b »
2010-01-28 Give all subcommands an optional setup() function that will be called…
123 parse_args() {
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
124 # parse options
125 FLAGS "$@" || exit $?
126 eval set -- "${FLAGS_ARGV}"
127
128 # read arguments into global variables
c5fcc01a »
2010-02-10 Do not quote variable assignments.
129 VERSION=$1
130 BASE=$2
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
131 BRANCH=$PREFIX$VERSION
132 }
133
134 require_version_arg() {
b866b01b »
2010-01-28 Give all subcommands an optional setup() function that will be called…
135 if [ "$VERSION" = "" ]; then
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
136 warn "Missing argument <version>"
b866b01b »
2010-01-28 Give all subcommands an optional setup() function that will be called…
137 usage
138 exit 1
139 fi
140 }
141
010252a8 »
2010-02-04 Added an optional <base> argument to all start subactions.
142 require_base_arg() {
143 if [ "$BASE" = "" ]; then
144 warn "Missing argument <base>"
145 usage
146 exit 1
147 fi
148 }
149
150 require_base_is_on_master() {
cf3da5a7 » adamgibbins
2010-08-22 Fixed incorrect color flag
151 if ! git branch --no-color --contains "$BASE" 2>/dev/null \
010252a8 »
2010-02-04 Added an optional <base> argument to all start subactions.
152 | sed 's/[* ] //g' \
153 | grep -q "^$MASTER_BRANCH\$"; then
154 die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'."
155 fi
156 }
157
00ccea60 » hollow
2010-01-26 refactor the whole thing
158 cmd_start() {
de95e004 »
2010-07-22 Change the default behaviour of all scripts to NOT fetch.
159 DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
00ccea60 » hollow
2010-01-26 refactor the whole thing
160 parse_args "$@"
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
161 require_version_arg
010252a8 »
2010-02-04 Added an optional <base> argument to all start subactions.
162 require_base_arg
163 require_base_is_on_master
00ccea60 » hollow
2010-01-26 refactor the whole thing
164
165 # sanity checks
7832d6ef »
2010-02-21 Better naming of common functions categorizing them into common,
166 require_clean_working_tree
00ccea60 » hollow
2010-01-26 refactor the whole thing
167
2acfffd9 »
2010-01-29 Make the 'to fetch or not to fetch' flag explicit in the other comman…
168 # fetch remote changes
ca73caf8 »
2010-02-07 Replaced all old-style flag variables by shFlags-style flag variables.
169 if flag fetch; then
a4dd223d »
2010-02-10 Quote all variables in function/program arguments.
170 git fetch -q "$ORIGIN" "$BASE"
2acfffd9 »
2010-01-29 Make the 'to fetch or not to fetch' flag explicit in the other comman…
171 fi
7832d6ef »
2010-02-21 Better naming of common functions categorizing them into common,
172 require_branch_absent "$BRANCH"
2acfffd9 »
2010-01-29 Make the 'to fetch or not to fetch' flag explicit in the other comman…
173
00ccea60 » hollow
2010-01-26 refactor the whole thing
174 # create branch
3c337fb5 »
2010-02-04 Added -v (--verbose) flags to list subaction of all subcommands.
175 git checkout -b "$BRANCH" "$BASE"
00ccea60 » hollow
2010-01-26 refactor the whole thing
176
177 echo
178 echo "Summary of actions:"
010252a8 »
2010-02-04 Added an optional <base> argument to all start subactions.
179 echo "- A new branch '$BRANCH' was created, based on '$BASE'"
00ccea60 » hollow
2010-01-26 refactor the whole thing
180 echo "- You are now on branch '$BRANCH'"
181 echo
182 }
Something went wrong with that request. Please try again.