blob: 7fbef519e18aef7ab891e609bdb6b1f379c10b9e [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
Vincent Driessen4f1cc332010-01-25 16:44:57 +010015# Get the git dir
16GIT_DIR=$(git rev-parse --git-dir)
17
18# Get all available branches
19LOCAL_BRANCHES=$(cd "$GIT_DIR/refs/heads"; find * -type f)
20REMOTE_BRANCHES=$(cd "$GIT_DIR/refs/remotes"; find * -type f)
21ALL_BRANCHES="$LOCAL_BRANCHES\n$REMOTE_BRANCHES"
22
Vincent Driessena0434ca2010-01-25 17:28:22 +010023warn() { echo "$@" >&2; }
24die() { warn "$@"; exit 1; }
Vincent Driessen4f1cc332010-01-25 16:44:57 +010025
Vincent Driessen61ade552010-01-21 01:28:08 +010026gitflow_check_clean_working_tree() {
Vincent Driessen4f1cc332010-01-25 16:44:57 +010027 # TODO: Implement this
28 echo "TODO"
29}
30
31gitflow_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
38gitflow_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
45gitflow_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 Driessen61ade552010-01-21 01:28:08 +010050}
51