diff options
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +#!/bin/bash + +# Add a pattern into gitignore +function hydra_git_ignore { + if [ ! -z "$BASEDIR/.gitignore" ]; then + echo $1 > $BASEDIR/.gitignore + hydra_exec git $BASEDIR add .gitignore + else + if ! grep -q -e "^$1$" $BASEDIR/.gitignore; then + echo $1 >> $BASEDIR/.gitignore + fi + fi +} + +# Check if a folder is inside a git repository +function hydra_is_git { + if [ -z "$1" ]; then + false + elif [ ! -d "$1" ]; then + false + elif [ -d "$1/.git" ]; then + true + else + cwd="`pwd`" + cd $1 && git="`git status &> /dev/null`" && cd $cwd + + if [ "$git" != "128" ]; then + true + else + false + fi + fi +} |