blob: 7e088c850f77d8a00ef6be1a637c6f0ac2afb071 [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 Driessen170dc742010-01-28 00:20:51 +010019 echo "usage: git flow release"
20 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
35parse_args() {
36 VERSION="$1"
37 if [ "$VERSION" = "" ]; then
38 echo "Missing argument <version>."
39 usage
40 exit 1
41 fi
Benedikt Böhm96f44c02010-01-26 13:09:32 +010042 BRANCH=$PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010043}
44
Vincent Driessen170dc742010-01-28 00:20:51 +010045cmd_default() {
Vincent Driessen170dc742010-01-28 00:20:51 +010046 RELEASE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
47 if [ -z "$RELEASE_BRANCHES" ]; then
48 warn "No release branches exist."
49 exit 0
50 fi
51 echo "$RELEASE_BRANCHES" | sed "s?^$PREFIX??g"
52}
53
Benedikt Böhm00ccea62010-01-26 12:39:36 +010054cmd_help() {
55 usage
56 exit 0
57}
58
59cmd_start() {
60 parse_args "$@"
61
62 # sanity checks
63 gitflow_check_clean_working_tree
Benedikt Böhm4d222272010-01-26 14:46:56 +010064 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010065 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010066 gitflow_require_branch_absent $BRANCH
67
68 # create branch
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010069 git checkout -b $BRANCH $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010070
71 echo
72 echo "Summary of actions:"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010073 echo "- A new branch '$BRANCH' was created, based on '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +010074 echo "- You are now on branch '$BRANCH'"
75 echo
76 echo "Follow-up actions:"
77 echo "- Bump the version number now!"
78 echo "- Start committing last-minute fixes in preparing your release"
79 echo "- When done, run:"
80 echo
81 echo " git flow finish release '$VERSION'"
82 echo
83}
84
85cmd_finish() {
86 parse_args "$@"
87
88 # sanity checks
89 gitflow_check_clean_working_tree
Benedikt Böhm4d222272010-01-26 14:46:56 +010090 git fetch -q $ORIGIN
Benedikt Böhm350e7152010-01-26 13:05:05 +010091 gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
92 gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010093
94 # merge into master
Benedikt Böhm4a864fb2010-01-26 12:59:27 +010095 git checkout $MASTER_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +010096 git merge --no-ff $BRANCH
Benedikt Böhmb22a0762010-01-28 01:07:06 +080097 git tag $VERSION_PREFIX$VERSION
Benedikt Böhm00ccea62010-01-26 12:39:36 +010098
99 # merge into develop
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100100 git checkout $DEVELOP_BRANCH
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100101 git merge --no-ff $BRANCH
102
103 # delete branch
104 git branch -d $BRANCH
105
106 # TODO: Implement an optional push to master
107 # git push origin develop; git push origin master; git push --tags origin
108
109 echo
110 echo "Summary of actions:"
Benedikt Böhm350e7152010-01-26 13:05:05 +0100111 echo "- Latest objects have been fetched from '$ORIGIN'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100112 echo "- Release branch has been merged into '$MASTER_BRANCH'"
Vincent Driessen3911e162010-01-27 22:20:47 +0100113 echo "- The release was tagged '$VERSION_PREFIX$VERSION'"
Benedikt Böhm4a864fb2010-01-26 12:59:27 +0100114 echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
Benedikt Böhm00ccea62010-01-26 12:39:36 +0100115 echo "- Release branch '$BRANCH' has been deleted"
116 echo
117}