blob: 74bdc9a9d0e81b247be69817ad3f344b4024779b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/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 &> /dev/null
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
}
# Initialize a repository
function hydra_git_init {
local repo="$1"
if [ -z "$repo" ] || [ ! -d "$repo" ] || [ -d "$repo/.git" ]; then
return
fi
(
echo "Initializing git repo $repo..."
cd $repo
git init
git add .
git commit -m "Initial import"
)
}
|