Vincent Driessen | 61ade55 | 2010-01-21 01:28:08 +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 | 61ade55 | 2010-01-21 01:28:08 +0100 | [diff] [blame] | 14 | |
Vincent Driessen | 4f1cc33 | 2010-01-25 16:44:57 +0100 | [diff] [blame] | 15 | # Get the git dir |
| 16 | GIT_DIR=$(git rev-parse --git-dir) |
| 17 | |
| 18 | # Get all available branches |
| 19 | LOCAL_BRANCHES=$(cd "$GIT_DIR/refs/heads"; find * -type f) |
| 20 | REMOTE_BRANCHES=$(cd "$GIT_DIR/refs/remotes"; find * -type f) |
| 21 | ALL_BRANCHES="$LOCAL_BRANCHES\n$REMOTE_BRANCHES" |
| 22 | |
Vincent Driessen | a0434ca | 2010-01-25 17:28:22 +0100 | [diff] [blame^] | 23 | warn() { echo "$@" >&2; } |
| 24 | die() { warn "$@"; exit 1; } |
Vincent Driessen | 4f1cc33 | 2010-01-25 16:44:57 +0100 | [diff] [blame] | 25 | |
Vincent Driessen | 61ade55 | 2010-01-21 01:28:08 +0100 | [diff] [blame] | 26 | gitflow_check_clean_working_tree() { |
Vincent Driessen | 4f1cc33 | 2010-01-25 16:44:57 +0100 | [diff] [blame] | 27 | # TODO: Implement this |
| 28 | echo "TODO" |
| 29 | } |
| 30 | |
| 31 | gitflow_require_local_branch() { |
| 32 | echo "$LOCAL_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null |
| 33 | if [ $? -ne 0 ]; then |
| 34 | die "Local branch '$1' does not exist and is required." |
| 35 | fi |
| 36 | } |
| 37 | |
| 38 | gitflow_require_remote_branch() { |
| 39 | echo "$REMOTE_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null |
| 40 | if [ $? -ne 0 ]; then |
| 41 | die "Remote branch '$1' does not exist and is required." |
| 42 | fi |
| 43 | } |
| 44 | |
| 45 | gitflow_require_branch() { |
| 46 | echo "$ALL_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null |
| 47 | if [ $? -ne 0 ]; then |
| 48 | die "Branch '$1' does not exist and is required." |
| 49 | fi |
Vincent Driessen | 61ade55 | 2010-01-21 01:28:08 +0100 | [diff] [blame] | 50 | } |
| 51 | |