blob: 7ee84598e19ce5384daa259b6396dd0db39385e9 [file] [log] [blame]
Vincent Driessen61ade552010-01-21 01:28:08 +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 Driessen61ade552010-01-21 01:28:08 +010014
15usage() {
16 echo "usage: gitflow start hotfix <release>"
17 echo " gitflow finish hotfix <release>"
18}
19
Vincent Driessenf7f687c2010-01-21 01:32:18 +010020parse_args() {
21 RELEASE="$1"
22 if [ "$RELEASE" = "" ]; then
23 echo "Missing argument <release>."
24 usage
25 exit 1
26 fi
Vincent Driessen3d412552010-01-25 22:16:08 +010027 HOTFIX_BRANCH="hotfix-$RELEASE"
Vincent Driessenf7f687c2010-01-21 01:32:18 +010028}
29
Vincent Driessen61ade552010-01-21 01:28:08 +010030start() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010031 parse_args "$@"
Vincent Driessen3d412552010-01-25 22:16:08 +010032
33 # Checks
Vincent Driessen61ade552010-01-21 01:28:08 +010034 gitflow_check_clean_working_tree
Vincent Driessen3d412552010-01-25 22:16:08 +010035 gitflow_require_branches_equal 'master' 'origin/master'
36 gitflow_require_branch_absent "$HOTFIX_BRANCH"
37
38 # All checks passed, ready to roll
39 echo "git checkout -b \"$HOTFIX_BRANCH\" master"
40 echo "Don't forget to bump the version number now."
Vincent Driessen61ade552010-01-21 01:28:08 +010041}
42
43finish() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010044 parse_args "$@"
Vincent Driessen3d412552010-01-25 22:16:08 +010045
46 # Checks
Vincent Driessen61ade552010-01-21 01:28:08 +010047 gitflow_check_clean_working_tree
Vincent Driessen3d412552010-01-25 22:16:08 +010048
49 echo "git fetch origin"
50 git fetch origin
51 gitflow_require_branches_equal 'master' 'origin/master'
52 gitflow_require_branches_equal 'develop' 'origin/develop'
53
54 # All checks passed, ready to roll
Vincent Driessen61ade552010-01-21 01:28:08 +010055 echo "git checkout master"
Vincent Driessen3d412552010-01-25 22:16:08 +010056 echo "git merge --no-ff \"$HOTFIX_BRANCH\""
57 echo "git tag \"$RELEASE\""
Vincent Driessen61ade552010-01-21 01:28:08 +010058 echo "git checkout develop"
Vincent Driessen3d412552010-01-25 22:16:08 +010059 echo "git merge --no-ff \"$HOTFIX_BRANCH\""
60 echo "git branch -d \"$HOTFIX_BRANCH\""
Vincent Driessen61ade552010-01-21 01:28:08 +010061}
62