Blame view

trunk/scripts/git.commit.sh 1.8 KB
winlin authored
1 2
#!/bin/bash
winlin authored
3 4
cat <<END >>/dev/null
touch git-ensure-commit &&
winlin authored
5
echo "cd `pwd` && git checkout master &&" >git-ensure-commit &&
winlin authored
6
echo "bash `pwd`/git.commit.sh" >>git-ensure-commit &&
winlin authored
7 8 9 10
chmod +x git-ensure-commit &&
sudo rm -f /bin/git-ensure-commit &&
sudo mv git-ensure-commit /bin/git-ensure-commit
END
winlin authored
11
winlin authored
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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 "导入脚本成功"
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
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
47
ok_msg "remote check ok"
winlin authored
48
49 50 51
function sync_push()
{
    for ((;;)); do 
52
        git push $*
53
        ret=$?; if [[ 0 -ne $ret ]]; then 
winlin authored
54
            failed_msg "Retry for failed: git push $*"
winlin authored
55
            sleep 3
56 57
            continue
        else
winlin authored
58
            ok_msg "Success: git push $*"
59 60 61 62
        fi
        break
    done
}
winlin authored
63
winlin authored
64 65 66
sync_push --all origin
sync_push --all srs.csdn
sync_push --all srs.oschina
67
ok_msg "push refs ok"
winlin authored
68
69 70 71
sync_push --tags srs.csdn
sync_push --tags srs.oschina
ok_msg "push tags ok"
72
winlin authored
73
exit 0