svn post-commit hook :仅当某些文件发生更改时才更新 [英] svn post-commit hook : update only if certain file has changed

查看:28
本文介绍了svn post-commit hook :仅当某些文件发生更改时才更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我的服务器上有一个 SVN 存储库设置.我有一个提交后挂钩设置,它会更新到DEV"文件夹,这样当我提交更改时,它会自动推送到我服务器上的DEV"子域.

Okay so I have an SVN repo setup on my server. I have a post-commit hook setup that updates to a "DEV" folder so that when I commit changes, it automatically pushes to my "DEV" subdomain on my server.

我现在需要的是一种简单的方法,可以在我准备好后将其推送到我的实时"子域.Live"子域在同一台服务器上,实际上,它与 DEV 是相同的 svn update/... 命令,但路径不同.

What I need now is an easy way to push it to my "Live" subdomain when I am ready. The "Live" subdomain is on the same server, and in reality, it would be the same svn update /... command as with the DEV, but to a different path.

我想我的存储库中可以有一个特定的文件,也许我可以更改此文件,然后在我的提交后文件中设置某种条件,以便在特定的情况下也更新到我的实时"目录文件已更改.

I was thinking I could have a specific file in my repo, and maybe I could just change this file, and then make some sort of condition in my post-commit file to also update to my "live" dir if that specific file has changed.

但我不知道如何编写该代码.目前我的提交后文件如下所示:

But I don't know how to write that code. Currently my post-commit file looks like this:

#!/bin/sh

REPOS="$1"
REV="$2"

svn update /var/www/dev/public

我需要它基本上做到这一点(但显然要使用正确的语法)

I need it to basically do this (but with correct syntax, obviously)

#!/bin/sh

REPOS="$1"
REV="$2"

svn update /var/www/dev/public
if (pushLive.txt has changed) {
  svn update /var/www/live/public
}

有人有什么建议吗?

推荐答案

不确定这是否是最有效的方法,而且这第一种情况在技术上适用于名为pushLive.txt"的文件,无论目录如何,因此您可能想使用它或确保文件是唯一的...

not sure if this is the most efficient way, and also this the first case will technically work on a file called "pushLive.txt" regardless of dir, so you might wanna play with that or make sure file is unique...

#!/bin/sh

LOOK=/usr/bin/svnlook
REPOS="$1"
REV="$2"

for changes in `$LOOK changed $REPOS | awk '{print $1 "=" $2;}'`;
do

  idx=`expr index "$changes" =`;
  directory=${changes:$idx};
  action=${changes:0:$idx-1};

  case "$directory" in
    *pushLive.txt )
      case "$action" in
        "U" )
           svn update /var/www/dev/test/public
           ;;
      esac
      ;;
  esac
done

exit 0

这篇关于svn post-commit hook :仅当某些文件发生更改时才更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆