blob: d5542f847bca66a5a70cb3934fc37888e131f58e [file] [log] [blame]
Benedikt Böhm00ccea62010-01-26 12:39:36 +01001#
2# gitflow -- A collection of Git wrapper scripts to provide high-level
3# repository operations for Vincent Driessen's branching model:
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
15usage() {
16 echo "usage: git flow start hotfix <version> [<base>]"
17 echo " git flow finish hotfix <version> [<base>]"
18 # TODO
19 #echo ""
20 #echo "options:"
21 #echo "--option Explanation"
22 #echo ""
23 #echo "start-only options:"
24 #echo "--option Explanation"
25 #echo ""
26 #echo "finish-only options:"
27 #echo "--push Push to the origin repo when finished"
28}
29
30parse_args() {
31 VERSION="$1"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010032 BASE="${2:-$MASTER_BRANCH}"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010033 if [ "$VERSION" = "" ]; then
34 echo "Missing argument <version>."
35 usage
36 exit 1
37 fi
38 BRANCH=hotfix/$VERSION
39}
40
41cmd_help() {
42 usage
43 exit 0
44}
45
46cmd_start() {
47 parse_args "$@"
48
49 # sanity checks
50 gitflow_check_clean_working_tree
51 git fetch origin
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010052 gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010053 gitflow_require_branch_absent $BRANCH
54
55 # create branch
56 git checkout -b $BRANCH $BASE
57
58 echo
59 echo "Summary of actions:"
60 echo "- A new branch '$BRANCH' was created, based on '$BASE'"
61 echo "- You are now on branch '$BRANCH'"
62 echo
63 echo "Follow-up actions:"
64 echo "- Bump the version number now!"
65 echo "- Start committing your hot fixes"
66 echo "- When done, run:"
67 echo
68 echo " git flow finish hotfix '$HOTFIX_BRANCH'"
69 echo
70}
71
72cmd_finish() {
73 parse_args "$@"
74
75 # sanity checks
76 gitflow_check_clean_working_tree
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010077 git fetch origin $MASTER_BRANCH
78 git fetch origin $DEVELOP_BRANCH
79 gitflow_require_branches_equal $MASTER_BRANCH origin/$MASTER_BRANCH
80 gitflow_require_branches_equal $DEVELOP_BRANCH origin/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010081
82 # merge into BASE
83 git checkout $BASE
84 git merge --no-ff $BRANCH
85 git tag v$VERSION
86
87 # merge into develop if we fixed a master issue
88 # TODO: merge into support branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010089 if [ "$BASE" = "$MASTER_BRANCH" ]; then
90 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010091 git merge --no-ff $BRANCH
92 fi
93
94 # delete branch
95 git branch -d $BRANCH
96
97 # TODO: Implement an optional push to master
98 # git push origin develop; git push origin master; git push --tags origin
99
100 echo
101 echo "Summary of actions:"
102 echo "- Latest objects have been fetched from 'origin'"
103 echo "- Hotfix branch has been merged into '$BASE'"
104 echo "- The hotfix was tagged 'v$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100105 if [ "$BASE" = "$MASTER_BRANCH" ]; then
106 echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100107 fi
108 echo "- Hotfix branch '$BRANCH' has been deleted"
109 echo
110}