blob: 3f5683e9c0293d7cede3b378e8e2509cd4e123d4 [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
51 git fetch origin
52 gitflow_require_branches_equal develop origin/develop
53 gitflow_require_branch_absent $BRANCH
54
55 # create branch
56 git checkout -b $BRANCH develop
57
58 echo
59 echo "Summary of actions:"
60 echo "- A new branch '$BRANCH' was created, based on 'develop'"
61 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
77 git fetch origin
78 gitflow_require_branches_equal master origin/master
79 gitflow_require_branches_equal develop origin/develop
80
81 # merge into master
82 git checkout master
83 git merge --no-ff $BRANCH
84 git tag v$VERSION
85
86 # merge into develop
87 git checkout develop
88 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:"
98 echo "- Latest objects have been fetched from 'origin'"
99 echo "- Release branch has been merged into 'master'"
100 echo "- The release was tagged 'v$VERSION'"
101 echo "- Release branch has been back-merged into 'develop'"
102 echo "- Release branch '$BRANCH' has been deleted"
103 echo
104}