Skip to content
Newer
Older
100644 124 lines (108 sloc) 3.04 KB
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
1 #
6c2d30b @nvie Structurally replace gitflow by git-flow, as a true git extension.
authored Jan 26, 2010
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 Jan 26, 2010
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
15 usage() {
186d2b5 @nvie Refactored the subcommand invocation logic to form a more hierarchica…
authored Jan 27, 2010
16 echo "usage: git flow hotfix"
17 echo " git flow hotfix start <version> [<base>]"
18 echo " git flow hotfix finish <version> [<base>]"
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
19 # TODO
20 #echo ""
21 #echo "options:"
22 #echo "--option Explanation"
23 #echo ""
24 #echo "start-only options:"
25 #echo "--option Explanation"
26 #echo ""
27 #echo "finish-only options:"
28 #echo "--push Push to the origin repo when finished"
29 }
30
31 parse_args() {
32 VERSION="$1"
4a864fb @hollow make master and develop branch names configurable
hollow authored Jan 26, 2010
33 BASE="${2:-$MASTER_BRANCH}"
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
34 if [ "$VERSION" = "" ]; then
35 echo "Missing argument <version>."
36 usage
37 exit 1
38 fi
96f44c0 @hollow make branch prefixes configurable
hollow authored Jan 26, 2010
39 PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
40 BRANCH=$PREFIX$VERSION
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
41 }
42
186d2b5 @nvie Refactored the subcommand invocation logic to form a more hierarchica…
authored Jan 27, 2010
43 cmd_default() {
44 # TODO: Refactor getting this prefix into a general function
45 PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
46 HOTFIX_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
47 if [ -z "$HOTFIX_BRANCHES" ]; then
48 warn "No hotfix branches exist."
49 exit 0
50 fi
51 echo "$HOTFIX_BRANCHES" | sed "s?^$PREFIX??g"
52 }
53
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
54 cmd_help() {
55 usage
56 exit 0
57 }
58
59 cmd_start() {
60 parse_args "$@"
61
62 # sanity checks
63 gitflow_check_clean_working_tree
4d22227 @hollow make git fetch silent
hollow authored Jan 26, 2010
64 git fetch -q $ORIGIN
350e715 @hollow make origin configurable
hollow authored Jan 26, 2010
65 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
66 gitflow_require_branch_absent $BRANCH
67
68 # create branch
69 git checkout -b $BRANCH $BASE
70
71 echo
72 echo "Summary of actions:"
73 echo "- A new branch '$BRANCH' was created, based on '$BASE'"
74 echo "- You are now on branch '$BRANCH'"
75 echo
76 echo "Follow-up actions:"
77 echo "- Bump the version number now!"
78 echo "- Start committing your hot fixes"
79 echo "- When done, run:"
80 echo
81 echo " git flow finish hotfix '$HOTFIX_BRANCH'"
82 echo
83 }
84
85 cmd_finish() {
86 parse_args "$@"
87
88 # sanity checks
89 gitflow_check_clean_working_tree
4d22227 @hollow make git fetch silent
hollow authored Jan 26, 2010
90 git fetch -q $ORIGIN $MASTER_BRANCH
91 git fetch -q $ORIGIN $DEVELOP_BRANCH
350e715 @hollow make origin configurable
hollow authored Jan 26, 2010
92 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
93 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
94
95 # merge into BASE
96 git checkout $BASE
97 git merge --no-ff $BRANCH
98 git tag v$VERSION
99
100 # merge into develop if we fixed a master issue
101 # TODO: merge into support branch
4a864fb @hollow make master and develop branch names configurable
hollow authored Jan 26, 2010
102 if [ "$BASE" = "$MASTER_BRANCH" ]; then
103 git checkout $DEVELOP_BRANCH
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
104 git merge --no-ff $BRANCH
105 fi
106
107 # delete branch
108 git branch -d $BRANCH
109
110 # TODO: Implement an optional push to master
111 # git push origin develop; git push origin master; git push --tags origin
112
113 echo
114 echo "Summary of actions:"
350e715 @hollow make origin configurable
hollow authored Jan 26, 2010
115 echo "- Latest objects have been fetched from '$ORIGIN'"
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
116 echo "- Hotfix branch has been merged into '$BASE'"
117 echo "- The hotfix was tagged 'v$VERSION'"
4a864fb @hollow make master and develop branch names configurable
hollow authored Jan 26, 2010
118 if [ "$BASE" = "$MASTER_BRANCH" ]; then
119 echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
00ccea6 @hollow refactor the whole thing
hollow authored Jan 26, 2010
120 fi
121 echo "- Hotfix branch '$BRANCH' has been deleted"
122 echo
123 }
Something went wrong with that request. Please try again.