如何创建一个颠覆服务器钩子脚本,如果人们不首先拥有文件的锁,就可以防止他们提交更改?
svn 服务器在 windows 上。
谢谢。
PS 这个问题的附加信息
如何创建一个颠覆服务器钩子脚本,如果人们不首先拥有文件的锁,就可以防止他们提交更改?
svn 服务器在 windows 上。
谢谢。
PS 这个问题的附加信息
使用预提交挂钩。预提交挂钩接收 2 个参数:
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
您需要使用svnlook
来确定是否存在未锁定的 svn:needs-lock 文件。
要确定此提交更改的路径:
svnlook changed $1 --transaction $2
遍历'changed'中的文件($PATH
作为循环项)并确定svn:needs-lock,以及它们当前是否被锁定:
svnlook propget $REPOS-PATH svn:needs-lock $PATH
svnlook lock $1 $PATH
向 stderr 写入一个并返回非零值以在需要时中止此提交。
您可以使用<your repos directory>/hooks/pre-commit
和使用一些批处理脚本(甚至是完整的程序,只要它是可执行的就可以了)。如果返回0,则提交成功;否则它将失败。
请参阅post-lock.tmpl
同一目录中的示例。
# PRE-COMMIT HOOK
#
# The pre-commit hook is invoked before a Subversion txn is
# committed. Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
#
# The default working directory for the invocation is undefined, so
# the program should set one explicitly if it cares.
#
# If the hook program exits with success, the txn is committed; but
# if it exits with failure (non-zero), the txn is aborted, no commit
# takes place, and STDERR is returned to the client. The hook
# program can use the 'svnlook' utility to help it examine the txn.
#
# On a Unix system, the normal procedure is to have 'pre-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.