blob: cf4e008043d32bf01bc901d6d52e27e3b1655096 [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"
32 BASE="${2:-master}"
33 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
52 gitflow_require_branches_equal master origin/master
53 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
77 git fetch origin master
78 git fetch origin develop
79 gitflow_require_branches_equal master origin/master
80 gitflow_require_branches_equal develop origin/develop
81
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
89 if [ "$BASE" = "master" ]; then
90 git checkout develop
91 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'"
105 if [ "$BASE" = "master" ]; then
106 echo "- Hotfix branch has been back-merged into 'develop'"
107 fi
108 echo "- Hotfix branch '$BRANCH' has been deleted"
109 echo
110}