简体   繁体   English

Svn预提交挂钩没有被执行

[英]Svn pre-commit hook not getting executed

I have a Centos 7 virtual machine (VirtualBox guest) that is acting as my svn server, already configured svn -- mod_dav_svn and got everything working fine: can checkout and do commits. 我有一个Centos 7虚拟机(VirtualBox guest)作为我的svn服务器,已配置svn - mod_dav_svn并使一切工作正常:可以结帐并做提交。 The problem is that when adding a pre-commit hook and then try to commit from a windows machine (VirtualBox host) TortoiseSVN fails with this error 问题是,当添加预提交钩子然后尝试从Windows机器(VirtualBox主机)提交时TortoiseSVN失败并出现此错误

Commit blocked by pre-commit hook (exit code 255) with no output. 提交被预提交挂钩(退出代码255)阻止而没有输出。

from the httpd logs I got 从我得到的httpd日志

[client xx.xx.xx.xxx:57] Could not MERGE resource "/svn/testrepo/!svn/txn/5-2f" into "/svn/testrepo/trunk". [client xx.xx.xx.xxx:57]无法将资源“/ svn / testrepo /!svn / txn / 5-2f”合并到“/ svn / testrepo / trunk”中。 [500, #0] [500,#0]

all the permissions are set correctly, I even try 777 and it is not working unless I remove the hook. 所有权限都设置正确,我甚至尝试777,除非我删除钩子它不起作用。

This is the reference I followed for the set up: http://www.unixmen.com/install-subversion-centos-7/ 这是我设置的参考: http//www.unixmen.com/install-subversion-centos-7/

I'm wondering if there's something missing in my 10-subversion.conf file... 我想知道我的10-subversion.conf文件中是否缺少某些内容......

I'm using the default pre-commit, which has been set already as executable and the owner is apache user. 我正在使用默认的预提交,它已经设置为可执行文件,并且所有者是apache用户。 Another test I did was to delete all the code in the pre-commit script leaving only the "exit 0" instruction. 我做的另一个测试是删除预提交脚本中的所有代码,只留下“退出0”指令。

This is how my 10-subversion.conf file looks like: 这就是我的10-subversion.conf文件的样子:

    LoadModule dav_svn_module     modules/mod_dav_svn.so
    LoadModule authz_svn_module   modules/mod_authz_svn.so
    LoadModule dontdothat_module  modules/mod_dontdothat.so

    <Location /svn>
       DAV svn
       SVNParentPath /var/www/svn
       AuthType Basic
       AuthName "Subversion repositories"
       AuthUserFile /etc/svn-auth-users
       Require valid-user
    </Location>
CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION

Finally got a solution for this. 终于得到了解决方案。 The root cause was the SELinux not allowing the pre-commit script to get executed through the httpd service. 根本原因是SELinux不允许通过httpd服务执行预提交脚本。 I get rid of that by running this line 我通过运行这条线来摆脱它

chcon -t httpd_exec_t pre-commit

Thanks everyone! 感谢大家! I hope this to be helpful for someone else. 我希望这对其他人有所帮助。

can you post your precommit script? 你可以发布你的预先提交脚本吗? If not, add following to your ".sh" script. 如果没有,请在“.sh”脚本中添加以下内容。

set -xv

at the line after 在后面的线

#!/bin/bash

looks finally: 最终看起来:

#!/bin/bash
set -xv

If this does not provide you more logging, redirect the outputs to a file in your script. 如果这不能为您提供更多日志记录,请将输出重定向到脚本中的文件。 So you can debug your script. 所以你可以调试你的脚本。

You can also increase the logging in your apache. 您还可以增加Apache中的日志记录。 Check this http://svnbook.red-bean.com/en/1.6/svn.serverconfig.httpd.html#svn.serverconfig.httpd.extra.logging 请查看http://svnbook.red-bean.com/en/1.6/svn.serverconfig.httpd.html#svn.serverconfig.httpd.extra.logging

So you will get one file only for SVN and you can play also with the log level. 所以你只能获得SVN的一个文件,你也可以使用日志级别。

I would personally first try, since easier the change of the script. 我个人会先尝试,因为更容易更改脚本。

(for your next question, please be more specific) (对于您的下一个问题,请更具体)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM