Android系统代码本地更新linux shell脚本1

本Linux shell脚本可以实现从远程服务器将代码更新到本地服务器上,提示开始实现把本地代码上传到远程服务器上(注意:# repo forall -c git push 53lo klink_weitf:klink 前的“#” 去掉 即可上传,53lo 为远程仓库名,klink_weitf为本地自己分支,klink为远程分支(与本地公测分支同名)),同时注意如果有修改没有提交,本脚本不会更新代码,如果代码自己分支与本地公测分支发送冲突,脚本不会上传代码。代码如下:sync.sh

#!/bin/bash

##########################################
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Check status:repo status"
repo status | tee status.log
STATUS=`cat status.log`
for i in $STATUS; do
    if [ "$i" == "-m" ];then
        break;
    fi
done

if [ "$i" != "-m" ];then
    echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    echo "checkout mtk:repo checkout mtk"
    repo checkout mtk

    if [ $? -eq 0 ]; then
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
        echo "Update project files:repo sync"
        repo sync
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
        echo "checkout klink:repo checkout klink"
        repo checkout klink
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
        echo "Pull code:repo forall -c git pull 53lo klink"
        repo forall -c git pull 53lo klink
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
        echo "checkout klink_weitf:repo checkout klink_weitf"
        repo checkout klink_weitf
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
        echo "Merge code:repo forall -c git merge klink"
        repo forall -c git merge klink
        echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
        echo "Check status:repo status"
        repo status | tee status.log
        STATUS=`cat status.log`
        for j in $STATUS
        do
            # echo $j
            if [ "$j" == "-m" ];then
                break
            fi
        done

        # if [ "$j" != "-m" ];then
        # modified by weitf @20150802
        if [ "$j" != "Um" ];then
            echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
            echo "Push code:repo forall -c git push 53lo klink_weitf:klink" 
            # repo forall -c git push 53lo klink_weitf:klink
            echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
            echo "Push code:push finish!!!"
            echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
            echo "sync finish($(date -d "today" +"%Y.%m.%d %H:%M:%S"))!!!"
        else
            echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
            echo "Merge error: CONFLICT!!!!($(date -d "today" +"%Y.%m.%d %H:%M:%S"))"
        fi

    # else

    #   echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    #   echo "error:sync error!!!!($(date -d "today" +"%Y.%m.%d %H:%M:%S"))"
    #   echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    #   echo "checkout klink_weitf:repo checkout klink_weitf"
    #   repo checkout klink_weitf
    #   echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    #   echo "Check status:repo status"
    #   repo status

    #   echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    #   echo "Commit error:no commit($(date -d "today" +"%Y.%m.%d %H:%M:%S"))"

    fi
else
    echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    echo "error:sync error!!!!($(date -d "today" +"%Y.%m.%d %H:%M:%S"))"
    echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    echo "checkout klink_weitf:repo checkout klink_weitf"
    repo checkout klink_weitf
    echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    echo "Check status:repo status"
    repo status

    echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    echo "Commit error:no commit($(date -d "today" +"%Y.%m.%d %H:%M:%S"))"
fi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值