blob: b4f242480e230d3cc69aeaf2c93e5661e773e2e0 [file] [log] [blame]
Vincent Driessenf7f687c2010-01-21 01:32:18 +01001#!/bin/sh
Vincent Driessen093a1472010-01-21 01:36:44 +01002#
3# gitflow -- A collection of Git wrapper scripts to provide high-level
4# repository operations for Vincent Driessen's branching model:
5#
6# Original blog post presenting this model is found at:
7# http://nvie.com/archives/323
8#
9# Feel free to contribute to this project at:
10# http://github.com/nvie/gitflow
11#
12# Copyright (c) 2010 by Vincent Driessen
13#
Vincent Driessenf7f687c2010-01-21 01:32:18 +010014
15usage() {
16 echo "usage: gitflow start release <release>"
17 echo " gitflow finish release <release>"
Vincent Driessen696b9eb2010-01-26 01:15:51 +010018 # 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"
Vincent Driessenf7f687c2010-01-21 01:32:18 +010029}
30
31parse_args() {
32 RELEASE="$1"
33 if [ "$RELEASE" = "" ]; then
Vincent Driessen696b9eb2010-01-26 01:15:51 +010034 echo "Missing argument <release>"
Vincent Driessenf7f687c2010-01-21 01:32:18 +010035 usage
36 exit 1
37 fi
Vincent Driessen3d412552010-01-25 22:16:08 +010038 RELEASE_BRANCH="release-$RELEASE"
Vincent Driessenf7f687c2010-01-21 01:32:18 +010039}
40
41start() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010042 parse_args "$@"
Vincent Driessen3d412552010-01-25 22:16:08 +010043
44 # Checks
Vincent Driessenf7f687c2010-01-21 01:32:18 +010045 gitflow_check_clean_working_tree
Vincent Driessen3d412552010-01-25 22:16:08 +010046 gitflow_require_branches_equal 'develop' 'origin/develop'
47 gitflow_require_branch_absent "$RELEASE_BRANCH"
48
49 # All checks passed, ready to roll
Vincent Driessen696b9eb2010-01-26 01:15:51 +010050 git checkout -b "$RELEASE_BRANCH" develop
51
52 echo ""
53 echo "Summary of actions:"
54 echo "- A new branch '$RELEASE_BRANCH' was created, based on 'develop'"
55 echo "- You are now on branch '$RELEASE_BRANCH'"
56 echo ""
57 echo "Follow-up actions:"
58 echo "- Bump the version number now!"
59 echo "- Start committing last-minute fixes in preparing your release"
60 echo "- When done, run:"
61 echo ""
62 echo " gitflow finish release '$RELEASE_BRANCH'"
Vincent Driessenf7f687c2010-01-21 01:32:18 +010063}
64
65finish() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010066 parse_args "$@"
Vincent Driessen3d412552010-01-25 22:16:08 +010067
68 # Checks
Vincent Driessenf7f687c2010-01-21 01:32:18 +010069 gitflow_check_clean_working_tree
Vincent Driessen3d412552010-01-25 22:16:08 +010070
Vincent Driessen696b9eb2010-01-26 01:15:51 +010071 git fetch origin develop # TODO: Make a flag to skip these fetches
72 git fetch origin master # TODO: Make a flag to skip these fetches
Vincent Driessen3d412552010-01-25 22:16:08 +010073 gitflow_require_branches_equal 'master' 'origin/master'
74 gitflow_require_branches_equal 'develop' 'origin/develop'
75
76 # All checks passed, ready to roll
Vincent Driessen696b9eb2010-01-26 01:15:51 +010077 git checkout master
78 git merge --no-ff "$RELEASE_BRANCH"
79 git tag "$RELEASE"
80 git checkout develop
81 git merge --no-ff "$RELEASE_BRANCH"
82 git branch -d "$RELEASE_BRANCH"
83
84 # TODO: Implement an optional push to master
85 # git push origin develop; git push origin master; git push --tags origin
86
87 echo ""
88 echo "Summary of actions:"
89 echo "- Latest objects have been fetched from 'origin'"
90 echo "- Release branch has been merged into 'master'"
91 echo "- The release was tagged '$RELEASE'"
92 echo "- Release branch has been back-merged into 'develop'"
93 echo "- Release branch '$RELEASE_BRANCH' has been deleted"
94 echo ""
Vincent Driessenf7f687c2010-01-21 01:32:18 +010095}
96