blob: ca5e360228c91777d93247b1cb067a3afb5afaeb [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 release <version>"
17 echo " git flow finish release <version>"
18 # TODO
19 #echo ""
20 #echo "options:"
21 #echo "--option Explanation"
22 #echo ""
23 #echo "start-only options:"
24 #echo "--bump <script>"
25 #echo " Run the given script to auto-update the version number"
26 #echo ""
27 #echo "finish-only options:"
28 #echo "--push Push to the origin repo when finished"
29}
30
31parse_args() {
32 VERSION="$1"
33 if [ "$VERSION" = "" ]; then
34 echo "Missing argument <version>."
35 usage
36 exit 1
37 fi
38 BRANCH=release/$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
Benedikt Böhm350e7152010-01-26 13:05:05 +010051 git fetch $ORIGIN
52 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010053 gitflow_require_branch_absent $BRANCH
54
55 # create branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010056 git checkout -b $BRANCH $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010057
58 echo
59 echo "Summary of actions:"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010060 echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010061 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 last-minute fixes in preparing your release"
66 echo "- When done, run:"
67 echo
68 echo " git flow finish release '$VERSION'"
69 echo
70}
71
72cmd_finish() {
73 parse_args "$@"
74
75 # sanity checks
76 gitflow_check_clean_working_tree
Benedikt Böhm350e7152010-01-26 13:05:05 +010077 git fetch $ORIGIN
78 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
79 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010080
81 # merge into master
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010082 git checkout $MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010083 git merge --no-ff $BRANCH
84 git tag v$VERSION
85
86 # merge into develop
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010087 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010088 git merge --no-ff $BRANCH
89
90 # delete branch
91 git branch -d $BRANCH
92
93 # TODO: Implement an optional push to master
94 # git push origin develop; git push origin master; git push --tags origin
95
96 echo
97 echo "Summary of actions:"
Benedikt Böhm350e7152010-01-26 13:05:05 +010098 echo "- Latest objects have been fetched from '$ORIGIN'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010099 echo "- Release branch has been merged into '$MASTER_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100100 echo "- The release was tagged 'v$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100101 echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100102 echo "- Release branch '$BRANCH' has been deleted"
103 echo
104}