From 131f598ab5806d5f184f068b0d5b772d636a74e1 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 27 Nov 2014 07:47:39 +0800 Subject: [PATCH] use multiple remote to commit and sync with csdn+oschina. --- trunk/scripts/_log.sh | 2 +- trunk/scripts/_mirror.utils.sh | 95 --------------------------------- trunk/scripts/csdn.mirror.sh | 37 ------------- trunk/scripts/github.commit.sh | 46 +++++++++++++--- trunk/scripts/oschina.mirror.sh | 37 ------------- 5 files changed, 40 insertions(+), 177 deletions(-) delete mode 100755 trunk/scripts/_mirror.utils.sh delete mode 100755 trunk/scripts/csdn.mirror.sh delete mode 100755 trunk/scripts/oschina.mirror.sh diff --git a/trunk/scripts/_log.sh b/trunk/scripts/_log.sh index a91a2c820..3c09982f3 100755 --- a/trunk/scripts/_log.sh +++ b/trunk/scripts/_log.sh @@ -8,7 +8,7 @@ RED="\\e[31m" GREEN="\\e[32m" YELLOW="\\e[33m" BLACK="\\e[0m" -POS="\\e[110G" +POS="\\e[100G" # if need to log to file, change the log path. if [[ ! $log ]]; then diff --git a/trunk/scripts/_mirror.utils.sh b/trunk/scripts/_mirror.utils.sh deleted file mode 100755 index 01f961a5e..000000000 --- a/trunk/scripts/_mirror.utils.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - -############################################# -# help for the first checkout. -############################################# -function first_checkout() -{ - mirror_name=$1 - git_url=$2 - project_dir=$3 - sync_script=$4 - - failed_msg "当前分支不是${mirror_name}镜像"; - - cat </dev/null 2>&1 -ret=$?; if [[ 0 -ne $ret ]]; then - first_checkout "CSDN" \ - "git@code.csdn.net:winlinvip/srs-csdn.git" \ - "srs-csdn" "$work_dir/scripts/csdn.mirror.sh" - exit 0; -fi - -sync_master -sync_1_0_release -sync_push "CSDN" - -exit 0 diff --git a/trunk/scripts/github.commit.sh b/trunk/scripts/github.commit.sh index de4b04d2b..e6c54739c 100755 --- a/trunk/scripts/github.commit.sh +++ b/trunk/scripts/github.commit.sh @@ -20,14 +20,46 @@ cd $work_dir && git checkout master ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi ok_msg "导入脚本成功" -source $work_dir/scripts/_mirror.utils.sh +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 -git remote -v|grep github.com >/dev/null 2>&1 -ret=$?; if [[ 0 -ne $ret ]]; then - echo "current not under github.com branch" - exit -1; -fi +function sync_push() +{ + repository=$1 + branch=$2 + + for ((;;)); do + git push $repository $branch + ret=$?; if [[ 0 -ne $ret ]]; then + failed_msg "提交$repository/$branch分支失败,自动重试"; + continue + else + ok_msg "提交$repository/$branch分支成功" + fi + break + done + ok_msg "$repository/$branch同步git成功" +} -sync_push "Github" +sync_push origin master +sync_push origin 1.0release +sync_push srs.csdn master +sync_push srs.csdn 1.0release +sync_push srs.oschina master +sync_push srs.oschina 1.0release +ok_msg "sync push ok" exit 0 diff --git a/trunk/scripts/oschina.mirror.sh b/trunk/scripts/oschina.mirror.sh deleted file mode 100755 index 47841b529..000000000 --- a/trunk/scripts/oschina.mirror.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -echo "更新OSChina镜像的脚本" - -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 "导入脚本成功" - -source $work_dir/scripts/_mirror.utils.sh - -git remote -v|grep git.oschina.net >/dev/null 2>&1 -ret=$?; if [[ 0 -ne $ret ]]; then - first_checkout "OSChina" \ - "git@git.oschina.net:winlinvip/srs.oschina.git" \ - "srs.oschina" "$work_dir/scripts/oschina.mirror.sh" - exit 0; -fi - -sync_master -sync_1_0_release -sync_push "OSChina" - -exit 0