git_template 1.3 KB
Newer Older
ziix's avatar
ziix 已提交
1
#!/bin/sh
ziix's avatar
ziix 已提交
2

P
修改  
prgrmz01@163.com 已提交
3
export PYTHONPATH=/pubx/git-replace/
P
修改  
prgrmz01@163.com 已提交
4 5 6
echo "$*" > /tmp/_args
python /pubx/git-replace/replace_url.py /tmp/_args /tmp/_args.new
new_args=`cat /tmp/_args.new`
ziix's avatar
ziix 已提交
7 8 9 10

# $* : -c advice.detachedHead=false clone --depth 1 --branch main https://github.com/frida/glib.git glib
# new_args : -c advice.detachedHead=false clone --depth 1 --branch main git@gitcode.net/dependency/frida/glib.git glib

P
日志  
prgrmz01@163.com 已提交
11
echo "pwd:`pwd`; /usr/bin/git.original $new_args" >> /tmp/git.log
P
修改  
prgrmz01@163.com 已提交
12
/usr/bin/git.original  $new_args
13

14
#如果不含clone, 则处理完毕了
P
fix  
prgrmz01@163.com 已提交
15 16 17 18
cmdf=/tmp/`date +%s`
echo python -c "'s=\"${new_args}\";print(\" clone \" in s) '" > $cmdf
if [ "`sh -x $cmdf`" = "False" ] ; then
echo "not clone cmd[${new_args}],done" >> /tmp/git.log
19 20
exit 0
fi
21

P
fix  
prgrmz01@163.com 已提交
22

23
#含有clone, 才会检查子模块
24
#git clone https://github.com/frida/libpsl.git
25
#python -c 's="-c advice.detachedHead=false clone --depth 1 --branch main https://github.com/frida/glib.git glib"; s.replace("  "," "); print(s.split(" ")[-1])'
26

P
prgrmz01@163.com 已提交
27
git_dir_name=`python -c "s='$new_args'; s.replace('  ',' '); print(s.split(' ')[-1])"  `
28 29
git_dir="`pwd`/$git_dir_name"
gitmodules_path=${git_dir}/.gitmodules
P
fix  
prgrmz01@163.com 已提交
30
test -cmdf ${gitmodules_path} && python /pubx/git-replace/replace_gitmodules_url.py ${gitmodules_path}
31 32


P
fix  
prgrmz01@163.com 已提交
33
echo ok >> /tmp/git.log #这句并不是废话, 是为了使得本脚本的退出值为正常0