blob: aebffa1ef5dff4a8b6ed3206f3ecd6e875572b84 [file] [log] [blame]
Benedikt Böhm00ccea62010-01-26 12:39:36 +01001#
Vincent Driessen6c2d30b2010-01-26 22:18:36 +01002# git-flow -- A collection of Git extensions to provide high-level
3# repository operations for Vincent Driessen's branching model.
Benedikt Böhm00ccea62010-01-26 12:39:36 +01004#
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() {
Benedikt Böhmb22a0762010-01-28 01:07:06 +080032 VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
Benedikt Böhm00ccea62010-01-26 12:39:36 +010033 VERSION="$1"
34 if [ "$VERSION" = "" ]; then
35 echo "Missing argument <version>."
36 usage
37 exit 1
38 fi
Benedikt Böhm96f44c02010-01-26 13:09:32 +010039 PREFIX=$(git config --get gitflow.prefix.release || echo release/)
40 BRANCH=$PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010041}
42
43cmd_help() {
44 usage
45 exit 0
46}
47
48cmd_start() {
49 parse_args "$@"
50
51 # sanity checks
52 gitflow_check_clean_working_tree
Benedikt Böhm4d222272010-01-26 14:46:56 +010053 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010054 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010055 gitflow_require_branch_absent $BRANCH
56
57 # create branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010058 git checkout -b $BRANCH $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010059
60 echo
61 echo "Summary of actions:"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010062 echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010063 echo "- You are now on branch '$BRANCH'"
64 echo
65 echo "Follow-up actions:"
66 echo "- Bump the version number now!"
67 echo "- Start committing last-minute fixes in preparing your release"
68 echo "- When done, run:"
69 echo
70 echo " git flow finish release '$VERSION'"
71 echo
72}
73
74cmd_finish() {
75 parse_args "$@"
76
77 # sanity checks
78 gitflow_check_clean_working_tree
Benedikt Böhm4d222272010-01-26 14:46:56 +010079 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010080 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 master
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010084 git checkout $MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010085 git merge --no-ff $BRANCH
Benedikt Böhmb22a0762010-01-28 01:07:06 +080086 git tag $VERSION_PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010087
88 # merge into develop
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010089 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010090 git merge --no-ff $BRANCH
91
92 # delete branch
93 git branch -d $BRANCH
94
95 # TODO: Implement an optional push to master
96 # git push origin develop; git push origin master; git push --tags origin
97
98 echo
99 echo "Summary of actions:"
Benedikt Böhm350e7152010-01-26 13:05:05 +0100100 echo "- Latest objects have been fetched from '$ORIGIN'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100101 echo "- Release branch has been merged into '$MASTER_BRANCH'"
Vincent Driessen3911e162010-01-27 22:20:47 +0100102 echo "- The release was tagged '$VERSION_PREFIX$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100103 echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100104 echo "- Release branch '$BRANCH' has been deleted"
105 echo
106}