`

SVN钩子 start-commit.tmpl 统计用户上传计数

阅读更多

重写/%SVN_HOME%/Repos/hooks/start-commit.tmpl

改名为/%SVN_HOME%/Repos/hooks/start-commit

start-commit.tmpl修改如下:

 

#!/bin/sh

# START-COMMIT HOOK
#
# The start-commit hook is invoked before a Subversion txn is created
# in the process of doing a commit.  Subversion runs this hook
# by invoking a program (script, executable, binary, etc.) named
# 'start-commit' (for which this file is a template)
# with the following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] USER         (the authenticated user attempting to commit)
#
# 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 commit continues; but
# if it exits with failure (non-zero), the commit is stopped before
# a Subversion txn is created, and STDERR is returned to the client.
#
# On a Unix system, the normal procedure is to have 'start-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
#
# Note that 'start-commit' must be executable by the user(s) who will
# invoke it (typically the user httpd runs as), and that user must
# have filesystem-level permission to access the repository.
#
# On a Windows system, you should name the hook program
# 'start-commit.bat' or 'start-commit.exe',
# but the basic idea is the same.
# 
# The hook program typically does not inherit the environment of
# its parent process.  For example, a common problem is for the
# PATH environment variable to not be set to its usual value, so
# that subprograms fail to launch unless invoked via absolute path.
# If you're having unexpected problems with a hook program, the
# culprit may be unusual (or missing) environment variables.
# 
# Here is an example hook script, for a Unix /bin/sh interpreter.
# For more examples and pre-written hooks, see those in
# the Subversion repository at
# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and
# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/


REPOS=$1
USER=$2

#记录用户COMMIT次数的文件
RECORDPATH=/svn/Repos/commitRecord/$USER
if [ -f $RECORDPATH ]; then
	#从文件中读取已经上传的次数
	COMMIT_TIMES=`cat $RECORDPATH | awk '{print $1}'`
	#清除之前的记录
	rm -f $RECORDPATH
else
	COMMIT_TIMES=0;
fi
#把次数加一
COMMIT_TIMES=`expr ${COMMIT_TIMES} + 1`
#写次数到记录文件
echo $COMMIT_TIMES >> $RECORDPATH

#commit-allower.pl --repository $REPOS --user $USER || exit 1
#special-auth-check.py --user $USER --auth-level 3 || exit 1

# All checks passed, so allow the commit.
exit 0

 

分享到:
评论

相关推荐

    SVN钩子 之 pre-commit

    "pre-commit"钩子就是在用户尝试提交更改到仓库之前运行的脚本,它可以用于执行验证、权限检查等操作,以确保提交符合设定的规则。 `pre-commit.bat` 和 `pre-commit2.bat` 是两种可能的批处理文件,通常用于...

    windows下svn的pre-commit钩子

    用法:将本bat文件(不可改名)存在svn服务器端安装目录\仓库名\hooks下(该目录下有多个*.tmpl文件,包括pre-commit.tmpl即linux下的提交钩子,而pre-commit.bat为windows下的提交钩子),并修改文件中相应目录(共...

    svn-python-1.6.6.win32-py2.5.exe

    svn-python-1.6.6.win32-py2.5.exe

    SVN插件site-1.10.x-1.8.x.zip

    SVN(Subversion)是一种广泛使用的版本控制系统,用于管理文件和目录的变更历史。 SVN插件通常是集成在开发环境中,如Eclipse、IntelliJ IDEA等,以方便开发者进行版本控制操作,如提交、更新、合并和查看版本历史...

    TortoiseSVN-1.8.8.25755-x64-svn-1.8.10&AnkhSvn-2.5.12471.17

    标题中的"TortoiseSVN-1.8.8.25755-x64-svn-1.8.10"和"AnkhSvn-2.5.12471.17"指的是两个不同的Subversion(SVN)客户端工具。Subversion是一种版本控制系统,用于管理文件和目录的版本历史,对于软件开发团队协作...

    subversion中的pre-commit.bat

    Subversion 中的 pre-commit.bat Subversion 中的 Hook 机制是指在客户端与服务器端之间的交互过程中,服务器端可以根据需要执行某些操作,以确保提交的合法性和正确性。这些操作称为 Hook SCRIPT,其中包括 pre-...

    AnkhSvn-2.1.7444.278.msi & AnkhSvn-2.1.8420.8.msi

    AnkhSvn是一款深受开发人员喜爱的Subversion(SVN)客户端,专为Visual Studio集成。这个压缩包包含了两个不同版本的AnkhSvn插件:AnkhSvn-2.1.7444.278.msi和AnkhSvn-2.1.8420.8.msi。这两个版本可能在功能上有所...

    TortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msiTortoiseSVN-1.8.7.25475

    TortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msiTortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msiTortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msiTortoiseSVN-1.8.7.25475-x64-svn-1.8.9.msiTortoiseSVN-1.8.7.25475-x64-svn-...

    TortoiseSVN-1.14.5.29465-x64-svn-1.14.2.rar

    《TortoiseSVN-1.14.5.29465-x64-svn-1.14.2.rar:一个强大的版本控制系统工具》 TortoiseSVN,这个名字可能对许多开发者而言并不陌生,它是一个高度集成在Windows资源管理器中的Subversion(SVN)客户端。这个名为...

    TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi安装包

    每次修改后,用户可以提交(Commit)更改到服务器,确保所有团队成员都能看到最新的版本。 2. **更新与合并**:其他团队成员提交的更改可以通过Update操作同步到本地副本。如果发生冲突,TortoiseSVN会帮助用户解决...

    svn-python-1.4.6.win32-py2.5.exe

    svn-python-1.4.6.win32-py2.5.exe

    TortoiseSVN-1.9.1.26747-x64-svn-1.9.1.144185283

    SVN工具 TortoiseSVN-1.9.1.26747-x64-svn-1.9.1.1441852832

    SVN最新版 TortoiseSVN-1.4.5.10425-win32-svn-1.4.5.msi

    SVN的核心概念包括仓库(Repository)、工作副本(Working Copy)以及提交(Commit)等。 **TortoiseSVN** 是SVN的一个直观的GUI(图形用户界面)客户端,其特点在于与Windows资源管理器紧密集成。通过右键菜单,...

    SVN-1.10.5-64.zip

    这将确保在安装完成后,在bin目录下提供`svn.exe`,这是一个非常实用的命令行工具,允许用户通过命令行界面执行SVN操作,如`svn checkout`(检出)、`svn commit`(提交)、`svn update`(更新)和`svn diff`(差异...

    SVN-site-1.8.22.rar

    "SVN-site-1.8.22" 提供了这样的功能,它包含了所有必要的组件,允许用户在Eclipse内无缝地集成SVN工具链。 安装过程相对简单,只需将压缩包解压后得到的文件放入Eclipse的"dropins"目录。"dropins"目录是Eclipse...

    TortoiseSVN-1.14.1.29085-x64-svn-1.14.1.msi

    TortoiseSVN-1.14.1.29085-x64-svn-1.14.1.msi

    mod_dav_svn-1.6.12-1.rhel5.x86_64.rpm

    mod_dav_svn-1.6.12-1.rhel5.x86_64.rpm

    svn-1.4.5-setup.exe

    Subversion(SVN)是一个广泛使用的版本控制系统,其1.4.5版的安装程序文件名为"svn-1.4.5-setup.exe"。Subversion的主要功能是跟踪和管理项目中的文件和目录的变化,允许多个人协同工作,同时保持代码历史的完整性...

    svn-1.4.6-setup.exe

    svn-1.4.6-setup.exe

    svn-1.4.0-setup.exe

    svn-1.4.0-setup.exe 安装文件

Global site tag (gtag.js) - Google Analytics