blob: adad4816fa3661a0064d866ac6d7a7a3d795c065 [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 feature <name> [<base>]"
17 echo " gitflow finish feature <name>"
18}
19
20parse_args() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010021 FEATURE="$1"
Daniel Truemper21c34832010-01-24 12:11:15 +010022 if [ $# -eq 2 ]; then
23 BASE="$2"
24 else
25 BASE="develop"
26 fi
Vincent Driessenf7f687c2010-01-21 01:32:18 +010027 if [ "$FEATURE" = "" ]; then
28 echo "Missing argument <release>."
29 usage
30 exit 1
31 fi
32}
33
34start() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010035 parse_args "$@"
Vincent Driessen3d412552010-01-25 22:16:08 +010036
37 # Checks
Vincent Driessenf7f687c2010-01-21 01:32:18 +010038 gitflow_check_clean_working_tree
Vincent Driessen3d412552010-01-25 22:16:08 +010039 gitflow_require_branch_absent "$FEATURE"
40 if [ "$BASE" = "develop" ]; then
41 gitflow_require_branches_equal 'develop' 'origin/develop'
42 fi
43
44 # All checks passed, ready to roll
Vincent Driessenf7f687c2010-01-21 01:32:18 +010045 echo "git checkout -b $FEATURE $BASE"
46}
47
48finish() {
Vincent Driessenf7f687c2010-01-21 01:32:18 +010049 parse_args "$@"
Vincent Driessen3d412552010-01-25 22:16:08 +010050
51 # Checks
Vincent Driessenf7f687c2010-01-21 01:32:18 +010052 gitflow_check_clean_working_tree
Vincent Driessen3d412552010-01-25 22:16:08 +010053 gitflow_require_branch "$FEATURE"
54 if [ "$BASE" = "develop" ]; then
55 gitflow_require_branches_equal 'develop' 'origin/develop'
56 fi
57
58 # All checks passed, ready to roll
Vincent Driessenf7f687c2010-01-21 01:32:18 +010059 echo "git checkout $BASE"
60 echo "git merge --no-ff $FEATURE"
Vincent Driessen3d412552010-01-25 22:16:08 +010061 echo "git branch -d $FEATURE"
Vincent Driessenf7f687c2010-01-21 01:32:18 +010062}
63