shell 脚本合并分支到主干

 

svn copy -r 73 svn://xxx/branches/test/main/aBeauty.inc.php ./main/aBeauty.inc.php

 

svn merge -r 72:73 --ignore-ancestry svn://xxx/branches/test/main/aBeauty.inc.php ./main/aBeauty.inc.php

 

 

 

#!/bin/bash

# 加载公共函数
source ~/common.sh

#curr_dir=`dirname $(get_curr_dir $0)`
curr_dir=/usr/local/var/www/svn_tools
source $curr_dir"/config.sh"

PROGNAME=`basename $0`;
BRANCHES_URL=svn://xxx/xxx;

function usage() {
    echo "用法:"
    echo "      $PROGNAME 版本号"
}

if [[ $# == 0 ]]; then
    usage;
    exit;
fi

version=$1

expr $version + 1

if [ $? -ne 0 ]; then
    echo '版本号必须是数值'
    exit
fi

svn log -r $version -qv $BRANCHES_URL | grep / | awk "{print \$1\$2}" > /tmp/svn_merge_info

for f in `cat /tmp/svn_merge_info`
do
    svn_cmd=`echo ${f:0:1}`
    f=`echo $f | sed -e "s/^.//"`
    local_f=`echo $f | sed -e "s/\/branches\/[^/]*//" | sed -e "s/\/trunk//"`
    case $svn_cmd in
    A)
        tmp="svn copy -r $version ${BRANCHES_URL}$f .$local_f"
        ;;
    M)
        tmp="svn merge -r $((version-1)):$version --ignore-ancestry $BRANCHES_URL$f .$local_f"
        ;;
    D)
        tmp="svn del .$local_f"
        ;;
    *)
        echo "暂不支持的命令,请联系小刚"
        exit
        ;;
    esac

    echo '######################################################'
    echo "待执行命令:$tmp"
    echo ''
    echo "结果:"
    ttmp=`$tmp`
    result=$?
    echo $ttmp
    echo '######################################################'
    echo ''
    echo ''
    echo ''
done

if [[ -s '/tmp/svn_merge_info' ]]; then
    status=`svn info | grep "/trunk"`
    if [[ -n $status ]]; then
        echo ;
        #$curr_dir"/packjs_tuan_trunk.sh"
        #$PHP_BIN $curr_dir"/sszt_change_statics_version.php" '/tmp/svn_merge_info'
    fi
fi

 

common.sh

#!/bin/bash

 

function get_curr_dir()

{

    if [ -L $1 ]; then

        # 获取软连接所指向的文件名

        ls -l $1 | awk "{print \$11}"

    else

        echo $1

    fi  

return 0

       

if [ ! -f $real_file ]; then

    echo $real_file":不是正规文件" 

    exit

fi  

}

 

config.sh

 

#!/bin/bash

  

SVN_TOOLS_DIR=$(dirname $0)

PHP_BIN="/usr/local/Cellar/php54/5.4.37/bin/php"

~ 

posted on 2019-03-29 13:58  bandbandme  阅读(470)  评论(0编辑  收藏  举报