-
Notifications
You must be signed in to change notification settings - Fork 408
/
contribute-to-sreworks.sh
executable file
·52 lines (40 loc) · 1.32 KB
/
contribute-to-sreworks.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
45
46
47
48
49
50
51
#!/bin/bash
#
# sreworks_project_path/contribute-to-sreworks.sh "paas/appmanager"
#
SW_ROOT=$(cd `dirname $0`; pwd)
IS_GIT_ROOT=$(ls -l .git|wc -l|awk '{print $1}')
if [ "$IS_GIT_ROOT" = "0" ];then
echo ""
echo "Please run contribute-to-sreworks.sh in Git Project root path /"
exit 1
fi
# 判断目标路径是否存在
TARGET_PATH=$1
if [ ! -d ${SW_ROOT}/${TARGET_PATH} ];then
echo "Target app path not found"
exit 1
fi
# 只能拷贝到paas/saas这两个目录下
if [[ "$TARGET_PATH" =~ ^paas/.* ]] || [[ "$TARGET_PATH" =~ ^saas/.* ]] || [[ "$TARGET_PATH" =~ ^/paas/.* ]] || [[ "$TARGET_PATH" =~ ^/saas/.* ]]; then
echo "Path check ok"
else
echo "Please copy code to paas/* or saas/*"
echo ""
echo "List paas/"
ls -l ${SW_ROOT}/${TARGET_PATH}/paas/|grep -v "total "
echo ""
echo "List saas/"
ls -l ${SW_ROOT}/${TARGET_PATH}/saas/|grep -v "total "
exit 1
fi
# 将当前代码拷贝到一个临时目录,移除.git文件
rm -rf /tmp/tmp_sw_project
mkdir -p /tmp/tmp_sw_project
cp -r ./ /tmp/tmp_sw_project/
rm -rf /tmp/tmp_sw_project/.git
mv /tmp/tmp_sw_project ${SW_ROOT}/${TARGET_PATH}/../
mv ${SW_ROOT}/${TARGET_PATH}/../tmp_sw_project ${SW_ROOT}/${TARGET_PATH}.bak
rm -rf ${SW_ROOT}/${TARGET_PATH}
mv ${SW_ROOT}/${TARGET_PATH}.bak ${SW_ROOT}/${TARGET_PATH}
echo "Copy code ok"