zoukankan      html  css  js  c++  java
  • SVN导出差异版本更新的文件列表

    对于在服务器上没有使用版本控制的运维人员来说,每次SVN修改的文件都需要查看更改日志,一个个查找出来再更新到服务器,过程实在是痛苦
    那么有没有一种方法跑个命令比对一下版本就哗啦啦的把修改好的文件复制出来并且是相同的目录结构呢,答案是有的

    #!/bin/bash
     
    if [ ! $1 ] || [ ! $2 ] || [ ! $3 ] || [ ! $4 ]; then
        echo "Please enter a revision from, revision to, SVN repository, and target directory"
        exit
    fi
     
    # set up nice names for the incoming parameters to make the script more readable
    revision_from=$1
    revision_to=$2
    repository=$3
    target_directory=$4
     
    # the grep is needed so we only get added/modified files and not the deleted ones or anything else
    # if it's a modified directory it's " M" so won't show with this command (good)
    # if it's an added directory it's still "A" so will show with this command (not so good)
    
    # echo "svn diff --summarize -r$revision_from:$revision_to $repository | grep "^[AM]'"
     
    for line in `svn diff --summarize -r$revision_from:$revision_to $repository | grep "^[AM]"`
    do
        # each line in the above command in the for loop is split into two:
        # 1) the status line (containing A, M, AM, D etc)
        # 2) the full repository and filename string
        # so only export the file when it's not the status line
        if [ $line != "A" ] && [ $line != "AM" ] && [ $line != "M" ]; then
            # use sed to remove the repository from the full repo and filename
            filename=`echo "$line" |sed "s|$repository||g"`
            # don't export if it's a directory we've already created
            if [ ! -d $target_directory$filename ]; then
                directory=`dirname $filename`
                mkdir -p $target_directory$directory
                svn export -r $revision_to $line $target_directory$filename
            fi
        fi
    done
     
    # to summarize any deleted files or directories at the end of the script uncomment the following line
    #svn diff --summarize -r$revision_from:$revision_to $repository | grep "^[D]"
    
    

    直接把上面代码保存修改名称为svndiff,并加上可执行权限

    使用方法:

    svndiff 前一个版本号  后一个版本号  项目路径  导出的文件存放路径
    
    
  • 相关阅读:
    揭晓UX(用户体验)最大的秘密
    Js、jquery学习笔记
    网站建设之高速WEB的实现
    网站改版之指标分析
    Nodejs读写流
    Nodejs查找,读写文件
    网站建设之脚本加载
    如何利用CSS3编写一个满屏的布局
    如何设计自己的UI套件
    用requireJS进行模块化的网站开发
  • 原文地址:https://www.cnblogs.com/chriiess/p/8856229.html
Copyright © 2011-2022 走看看