blob: 14ac662a82d846dc0a96848f050adc69c74eafe8 [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
Benedikt Böhm96f44c02010-01-26 13:09:32 +010038 PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
39 BRANCH=$PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010040}
41
42cmd_help() {
43 usage
44 exit 0
45}
46
47cmd_start() {
48 parse_args "$@"
49
50 # sanity checks
51 gitflow_check_clean_working_tree
Benedikt Böhm350e7152010-01-26 13:05:05 +010052 git fetch $ORIGIN
53 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010054 gitflow_require_branch_absent $BRANCH
55
56 # create branch
57 git checkout -b $BRANCH $BASE
58
59 echo
60 echo "Summary of actions:"
61 echo "- A new branch '$BRANCH' was created, based on '$BASE'"
62 echo "- You are now on branch '$BRANCH'"
63 echo
64 echo "Follow-up actions:"
65 echo "- Bump the version number now!"
66 echo "- Start committing your hot fixes"
67 echo "- When done, run:"
68 echo
69 echo " git flow finish hotfix '$HOTFIX_BRANCH'"
70 echo
71}
72
73cmd_finish() {
74 parse_args "$@"
75
76 # sanity checks
77 gitflow_check_clean_working_tree
Benedikt Böhm350e7152010-01-26 13:05:05 +010078 git fetch $ORIGIN $MASTER_BRANCH
79 git fetch $ORIGIN $DEVELOP_BRANCH
80 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
81 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010082
83 # merge into BASE
84 git checkout $BASE
85 git merge --no-ff $BRANCH
86 git tag v$VERSION
87
88 # merge into develop if we fixed a master issue
89 # TODO: merge into support branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010090 if [ "$BASE" = "$MASTER_BRANCH" ]; then
91 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010092 git merge --no-ff $BRANCH
93 fi
94
95 # delete branch
96 git branch -d $BRANCH
97
98 # TODO: Implement an optional push to master
99 # git push origin develop; git push origin master; git push --tags origin
100
101 echo
102 echo "Summary of actions:"
Benedikt Böhm350e7152010-01-26 13:05:05 +0100103 echo "- Latest objects have been fetched from '$ORIGIN'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100104 echo "- Hotfix branch has been merged into '$BASE'"
105 echo "- The hotfix was tagged 'v$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100106 if [ "$BASE" = "$MASTER_BRANCH" ]; then
107 echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100108 fi
109 echo "- Hotfix branch '$BRANCH' has been deleted"
110 echo
111}