blob: d42287dcd680cafccaa0f2b18c1f7cb800570a6f [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
Benedikt Böhm96f44c02010-01-26 13:09:32 +010038 PREFIX=$(git config --get gitflow.prefix.release || echo release/)
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 $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010054 gitflow_require_branch_absent $BRANCH
55
56 # create branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010057 git checkout -b $BRANCH $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010058
59 echo
60 echo "Summary of actions:"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010061 echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010062 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 last-minute fixes in preparing your release"
67 echo "- When done, run:"
68 echo
69 echo " git flow finish release '$VERSION'"
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
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 master
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010083 git checkout $MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010084 git merge --no-ff $BRANCH
85 git tag v$VERSION
86
87 # merge into develop
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010088 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010089 git merge --no-ff $BRANCH
90
91 # delete branch
92 git branch -d $BRANCH
93
94 # TODO: Implement an optional push to master
95 # git push origin develop; git push origin master; git push --tags origin
96
97 echo
98 echo "Summary of actions:"
Benedikt Böhm350e7152010-01-26 13:05:05 +010099 echo "- Latest objects have been fetched from '$ORIGIN'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100100 echo "- Release branch has been merged into '$MASTER_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100101 echo "- The release was tagged 'v$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100102 echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100103 echo "- Release branch '$BRANCH' has been deleted"
104 echo
105}