svnadds: 一键提交所有新增文件和修改文件

前端之家收集整理的这篇文章主要介绍了svnadds: 一键提交所有新增文件和修改文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

#!/bin/bash

#############################################
# usage:                                    #
#   svnadd                                  #
#   svnadd path                             #
#   svnadd path message                     #
#############################################

curdir='./'
choice=''
message=''

# check which directory you want to add svn.
if [ -n "${1}" ]; then
    curdir="${1}"
    if [ -n "${2}" ]; then
        message="${2}"
    fi
fi

# get the files you maybe want to add svn
files=`svn st ${curdir} | awk '/\?/ { print $2 }'`

if [ -z "${files}" ]; then
    echo 'no files to submit!'
    echo ''
    exit
fi

echo ''
echo 'The files that you maybe want to add svn:'
echo "START: [`date '+%Y-%m-%d %H:%M:%S'`] ---------->> "

for f in $files
do
    echo '    '$f
done

echo '-------->>'
echo -n 'Do you want to add the files to under the subversion? (y/n)'
read choice

while [ "${choice}" != "Y" -o "${choice}" != "y" ]
do
    if [ "${choice}" == "Y" -o "${choice}" == "y" ]; then
        for f in $files
        do
            echo "    Executing command: svn add ${curdir}/${f}"
            svn add "${curdir}/${f}"
        done
        echo "    Executing command: svn ci -m '' ${curdir}"
        svn ci -m "${message}"  "${curdir}"
        echo "END: [`date '+%Y-%m-%d %H:%M:%S'`] <<-------- "
        echo ''
        exit
    else
        if [ "${choice}" == "N" -o "${choice}" == "n" ]; then
            echo 'You have cannel to submit the files.'
            echo "END: [`date '+%Y-%m-%d %H:%M:%S'`] <<-------- "
            echo ''
            exit
        else
            echo -n 'The error choice,please input your choice(y/n):'
            read choice
        fi
    fi
done

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

猜你在找的Shell相关文章