blob: 7a102d146d829d22ad380dbec719cb2279288b0e [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
Benedikt Böhm49dd62b2010-01-28 00:51:15 +010015VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
16PREFIX=$(git config --get gitflow.prefix.release || echo release/)
17
Benedikt Böhm00ccea62010-01-26 12:39:36 +010018usage() {
Vincent Driessenb866b012010-01-28 01:01:53 +010019 echo "usage: git flow release [list]"
Vincent Driessen170dc742010-01-28 00:20:51 +010020 echo " git flow release start <version>"
21 echo " git flow release finish <version>"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010022 # TODO
23 #echo ""
24 #echo "options:"
25 #echo "--option Explanation"
26 #echo ""
27 #echo "start-only options:"
28 #echo "--bump <script>"
29 #echo " Run the given script to auto-update the version number"
30 #echo ""
31 #echo "finish-only options:"
32 #echo "--push Push to the origin repo when finished"
33}
34
Vincent Driessen170dc742010-01-28 00:20:51 +010035cmd_default() {
Vincent Driessenb866b012010-01-28 01:01:53 +010036 cmd_list "$@"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010037}
38
Vincent Driessenb866b012010-01-28 01:01:53 +010039cmd_list() {
Vincent Driessen170dc742010-01-28 00:20:51 +010040 RELEASE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
41 if [ -z "$RELEASE_BRANCHES" ]; then
42 warn "No release branches exist."
43 exit 0
44 fi
45 echo "$RELEASE_BRANCHES" | sed "s?^$PREFIX??g"
46}
47
Benedikt Böhm00ccea62010-01-26 12:39:36 +010048cmd_help() {
49 usage
50 exit 0
51}
52
Vincent Driessenb866b012010-01-28 01:01:53 +010053parse_args() {
54 VERSION="$1"
55 if [ "$VERSION" = "" ]; then
56 echo "Missing argument <version>."
57 usage
58 exit 1
59 fi
60 BRANCH=$PREFIX$VERSION
61}
62
Benedikt Böhm00ccea62010-01-26 12:39:36 +010063cmd_start() {
64 parse_args "$@"
65
66 # sanity checks
Vincent Driessen48386442010-01-29 10:30:40 +010067 gitflow_require_clean_working_tree
Benedikt Böhm4d222272010-01-26 14:46:56 +010068 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010069 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010070 gitflow_require_branch_absent $BRANCH
71
72 # create branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010073 git checkout -b $BRANCH $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010074
75 echo
76 echo "Summary of actions:"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010077 echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010078 echo "- You are now on branch '$BRANCH'"
79 echo
80 echo "Follow-up actions:"
81 echo "- Bump the version number now!"
82 echo "- Start committing last-minute fixes in preparing your release"
83 echo "- When done, run:"
84 echo
85 echo " git flow finish release '$VERSION'"
86 echo
87}
88
89cmd_finish() {
90 parse_args "$@"
91
92 # sanity checks
Vincent Driessen48386442010-01-29 10:30:40 +010093 gitflow_require_clean_working_tree
Benedikt Böhm4d222272010-01-26 14:46:56 +010094 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010095 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
96 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010097
98 # merge into master
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010099 git checkout $MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100100 git merge --no-ff $BRANCH
Benedikt Böhmb22a0762010-01-28 01:07:06 +0800101 git tag $VERSION_PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100102
103 # merge into develop
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100104 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100105 git merge --no-ff $BRANCH
106
107 # delete branch
108 git branch -d $BRANCH
109
110 # TODO: Implement an optional push to master
111 # git push origin develop; git push origin master; git push --tags origin
112
113 echo
114 echo "Summary of actions:"
Benedikt Böhm350e7152010-01-26 13:05:05 +0100115 echo "- Latest objects have been fetched from '$ORIGIN'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100116 echo "- Release branch has been merged into '$MASTER_BRANCH'"
Vincent Driessen3911e162010-01-27 22:20:47 +0100117 echo "- The release was tagged '$VERSION_PREFIX$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100118 echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100119 echo "- Release branch '$BRANCH' has been deleted"
120 echo
121}