1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 20:01:56 +00:00
srs/trunk/scripts/git.commit.sh

74 lines
1.8 KiB
Bash
Raw Normal View History

2014-11-26 23:02:54 +00:00
#!/bin/bash
2014-11-27 04:50:04 +00:00
cat <<END >>/dev/null
touch git-ensure-commit &&
2014-11-27 04:53:21 +00:00
echo "cd `pwd` && git checkout master &&" >git-ensure-commit &&
2014-11-27 04:52:47 +00:00
echo "bash `pwd`/git.commit.sh" >>git-ensure-commit &&
2014-11-27 04:50:04 +00:00
chmod +x git-ensure-commit &&
sudo rm -f /bin/git-ensure-commit &&
sudo mv git-ensure-commit /bin/git-ensure-commit
END
2014-11-27 04:45:34 +00:00
2014-11-26 23:02:54 +00:00
echo "submit code to github.com"
echo "argv[0]=$0"
if [[ ! -f $0 ]]; then
echo "directly execute the scripts on shell.";
work_dir=`pwd`
else
echo "execute scripts in file: $0";
work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)`
fi
work_dir=`(cd ${work_dir}/.. && pwd)`
product_dir=$work_dir
# allow start script from any dir
cd $work_dir && git checkout master
. ${product_dir}/scripts/_log.sh
ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi
ok_msg "导入脚本成功"
function remote_check()
{
remote=$1
url=$2
git remote -v| grep "$url" >/dev/null 2>&1
ret=$?; if [[ 0 -ne $ret ]]; then
echo "remote $remote not found, add by:"
echo " git remote add $remote $url"
exit -1
fi
ok_msg "remote $remote ok, url is $url"
}
remote_check origin git@github.com:winlinvip/simple-rtmp-server.git
remote_check srs.csdn git@code.csdn.net:winlinvip/srs-csdn.git
remote_check srs.oschina git@git.oschina.net:winlinvip/srs.oschina.git
2014-11-27 00:00:11 +00:00
ok_msg "remote check ok"
2014-11-26 23:02:54 +00:00
function sync_push()
{
for ((;;)); do
2014-11-27 00:00:11 +00:00
git push $*
ret=$?; if [[ 0 -ne $ret ]]; then
2014-11-27 04:51:33 +00:00
failed_msg "Retry for failed: git push $*"
2014-11-27 00:03:21 +00:00
sleep 3
continue
else
2014-11-27 04:51:33 +00:00
ok_msg "Success: git push $*"
fi
break
done
}
2014-11-26 23:02:54 +00:00
2014-11-27 00:02:17 +00:00
sync_push --all origin
sync_push --all srs.csdn
sync_push --all srs.oschina
2014-11-27 00:00:11 +00:00
ok_msg "push refs ok"
2014-11-26 23:02:54 +00:00
2014-11-27 00:00:11 +00:00
sync_push --tags srs.csdn
sync_push --tags srs.oschina
ok_msg "push tags ok"
2014-11-26 23:52:12 +00:00
2014-11-26 23:02:54 +00:00
exit 0