-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepo
executable file
·62 lines (56 loc) · 1.34 KB
/
repo
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
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
rhf="/usr/bin/recreatehostfiles"
if [ -e "$rhf" ]
then
/usr/bin/recreatehostfiles
rm "$rhf"
fi
if [ ${#} -eq 2 ]; then
projectname="${2}"
projectname=${projectname/.git/}
repodir="$projectname.git"
fi
cd /opt/git
case ${1} in
create)
if [ ${#} -eq 2 ]; then
echo "cd /opt/git" > ./tempScript.sh
echo "mkdir $repodir" >> ./tempScript.sh
echo "cd $repodir" >> ./tempScript.sh
echo "git --bare init" >> ./tempScript.sh
chmod ugo+x ./tempScript.sh
chown git: ./tempScript.sh
su -c /opt/git/tempScript.sh -s /bin/bash git
rm ./tempScript.sh
echo -e "\nUse following line to add this repo to your project ${projectname}: "
echo "git remote add origin git@gitserver:/opt/git/$repodir"
else
echo -e "Usage: repo create REPOSITORY"
fi
;;
rm|remove)
if [ ${#} -eq 2 ]; then
rm -rf "./$repodir"
if [ $? -eq 0 ]; then
echo "$projectname is removed"
else
echo "$projectname couldn't be removed"
fi
else
echo -e "Usage: repo rm REPOSITORY"
fi
;;
ls|list)
for project in `ls -1 .`;
do
echo ${project/.git/};
done
;;
*)
echo -e "Usage: repo COMMAND arg\n"
echo -e "A simple git repository control.\n"
echo "Commands:"
echo " create Creates repository"
echo " rm Removes repository"
echo " ls Lists repositories"
esac