-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.sh
45 lines (38 loc) · 1.21 KB
/
git.sh
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
#!/bin/bash
OLD_REPO_DIR=/git/repositories
NEW_REPO_DIR=/git-data/git
#OLD_REPO_DIR=/root/workspace/js/git/repositories
#NEW_REPO_DIR=/root/workspace/js/git/data/git
USERNAME_PREFIX=gitlab_www_
#rm -fr ${NEW_REPO_DIR}/*
#rm -fr ${OLD_REPO_DIR}
#tar -zxvf repo.tar.gz
for username in `ls ${OLD_REPO_DIR}`
do
prefix=${username:0:11}
if [ ${prefix} != ${USERNAME_PREFIX} ]; then
continue
fi
realname=${username:11}
#echo ${realname}
for reponame in `ls ${OLD_REPO_DIR}/${username}`
do
# continue .wiki.git
if [ "${reponame:0-9:9}" = ".wiki.git" -o "${reponame}" = "__keepwork__.git" ]; then
echo "continue ${reponame}"
continue;
fi
short_reponame=${reponame%.git}
old_repopath=${OLD_REPO_DIR}/${username}/${reponame}
new_reponame=`echo -n ${realname}/${short_reponame} | base64 -w 0`
new_repopath=${NEW_REPO_DIR}/${new_reponame}
#echo ${old_repopath}
#echo ${new_repopath}
if [ -e ${new_repopath} ]; then
echo ${new_repopath} already exist!!!
else
echo mv ${old_repopath} ${new_repopath}
#mv ${old_repopath} ${new_repopath}
fi
done
done