Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 1 | #!/bin/sh |
Vincent Driessen | 093a147 | 2010-01-21 01:36:44 +0100 | [diff] [blame] | 2 | # |
| 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 Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 14 | |
| 15 | usage() { |
| 16 | echo "usage: gitflow start feature <name> [<base>]" |
| 17 | echo " gitflow finish feature <name>" |
| 18 | } |
| 19 | |
| 20 | parse_args() { |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 21 | FEATURE="$1" |
Daniel Truemper | 21c3483 | 2010-01-24 12:11:15 +0100 | [diff] [blame] | 22 | if [ $# -eq 2 ]; then |
| 23 | BASE="$2" |
| 24 | else |
| 25 | BASE="develop" |
| 26 | fi |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 27 | if [ "$FEATURE" = "" ]; then |
| 28 | echo "Missing argument <release>." |
| 29 | usage |
| 30 | exit 1 |
| 31 | fi |
| 32 | } |
| 33 | |
| 34 | start() { |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 35 | parse_args "$@" |
Vincent Driessen | 3d41255 | 2010-01-25 22:16:08 +0100 | [diff] [blame^] | 36 | |
| 37 | # Checks |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 38 | gitflow_check_clean_working_tree |
Vincent Driessen | 3d41255 | 2010-01-25 22:16:08 +0100 | [diff] [blame^] | 39 | 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 Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 45 | echo "git checkout -b $FEATURE $BASE" |
| 46 | } |
| 47 | |
| 48 | finish() { |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 49 | parse_args "$@" |
Vincent Driessen | 3d41255 | 2010-01-25 22:16:08 +0100 | [diff] [blame^] | 50 | |
| 51 | # Checks |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 52 | gitflow_check_clean_working_tree |
Vincent Driessen | 3d41255 | 2010-01-25 22:16:08 +0100 | [diff] [blame^] | 53 | 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 Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 59 | echo "git checkout $BASE" |
| 60 | echo "git merge --no-ff $FEATURE" |
Vincent Driessen | 3d41255 | 2010-01-25 22:16:08 +0100 | [diff] [blame^] | 61 | echo "git branch -d $FEATURE" |
Vincent Driessen | f7f687c | 2010-01-21 01:32:18 +0100 | [diff] [blame] | 62 | } |
| 63 | |