svn:E165001:提交被预提交钩子(退出代码 255)阻止,没有输出.如何解决这个问题? [英] svn: E165001: Commit blocked by pre-commit hook (exit code 255) with no output. How can this be solved?

查看:265
本文介绍了svn:E165001:提交被预提交钩子(退出代码 255)阻止,没有输出.如何解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Phabricator 配置 svn.到目前为止,一切似乎都在工作,除了提交更改.当我尝试提交任何代码时,我收到以下错误消息:

I am trying to configure svn with Phabricator. Everything seems to be working so far, except for commiting changes. When I try to commit any code, I get the following error message:

svn: E165001: Commit blocked by pre-commit hook (exit code 255) with no output.

需要说明的是,有问题的错误消息是由 svn 客户端程序输出的.好像是svnserve遇到各种问题的时候发的,比如因为某些原因不能运行hook.它不必由钩子提供.

Just to be clear, the error message in question is output by the svn client program. It seems to be sent from svnserve when it encounters various issues, such as not being able to run the hook for some reason. It doesn't have to be provided by the hook.

如果我删除预提交钩子,提交会按预期进行.

If I delete the pre-commit hook, the commits go through as expected.

出于测试目的,我创建了一个非常简单的钩子,如下所示:

For testing purposes, I have created an extremely simple hook, that looks like this:

#!/bin/sh

echo "testing" >&2
exit 1

我在使用这个钩子时也收到了同样的错误信息. 在这种情况下,尝试解决一个更复杂的脚本没有多大意义,直到它可以工作.很可能通过解决这个脚本,原来的脚本也能正常工作.我一直在用这个脚本进行测试,我在这个问题中发布的所有内容都适用于这个脚本.基本上,此时此刻,我所展示的脚本确实是我正在努力制作的脚本.

I get the same error message when using this hook as well. This being the case, there is not much sense trying to solve for a more complicated script until this one can be made to work. It could very well be that by solving for this script, the original one will work as well. I have been testing with this script and all that I have posted in this question holds true for this script. Basically, at this point in time, the script I have presented really is the script I'm trying to make work.

我已经禁用了 Phabricator 守护进程,否则预提交脚本会被 Phabricator 覆盖.

I have disabled the Phabricator daemons, since otherwise the pre-commit script is overwritten by Phabricator.

以下是我认为可能有助于解决此问题的一些信息,基于我目前看到的有关此错误消息的内容:

The following is some information that I think may be helpful in solving this, based on what I've seen written about this error message so far:

  • 该存储库归运行 svnserve 的用户 phd 所有.
  • 预提交挂钩设置为可执行.
foven@phabricator:~$ sudo ls -la /var/repo/SVN/hooks/
total 60
drwxr-xr-x. 3 phd  phd   4096 Nov 18 13:46 .
drwxr-xr-x. 6 phd  phd   4096 Nov 18 11:27 ..
-rwxr-xr-x. 1 phd  phd   2062 Oct 27 10:17 post-commit.tmpl
-rwxr-xr-x. 1 phd  phd   1638 Oct 27 10:17 post-lock.tmpl
-rwxr-xr-x. 1 phd  phd   2289 Oct 27 10:17 post-revprop-change.tmpl
-rwxr-xr-x. 1 phd  phd   1567 Oct 27 10:17 post-unlock.tmpl
-rwxr-xr-x  1 phd  phd     37 Nov 18 14:39 pre-commit
drwxr-xr-x. 2 phd  phd     19 Nov 17 17:05 pre-commit-phabricator.d
-rwxr-xr-x. 1 phd  phd   3426 Nov 12 15:59 pre-commit.tmpl
-rwxr-xr-x. 1 phd  phd   2434 Oct 27 10:17 pre-lock.tmpl
-rwxr-xr-x. 1 phd  phd   2786 Oct 27 10:17 pre-revprop-change.tmpl
-rwxr-xr-x. 1 phd  phd   2122 Oct 27 10:17 pre-unlock.tmpl
-rwxr-xr-x. 1 phd  phd   3163 Oct 27 10:17 start-commit.tmpl

  • SELinux 被禁用/设置为宽松:
  • foven@phabricator:~$ sudo getenforce
    Disabled
    

    • 我已在预提交挂钩文件上运行 dos2unix:
    • foven@phabricator:~$ sudo dos2unix /var/repo/SVN/hooks/pre-commit
      dos2unix: converting file /var/repo/SVN/hooks/pre-commit to Unix format...
      

      • 我可以以用户 phd 的身份从命令行运行钩子脚本:
      • [phd@phabricator ~]$ /var/repo/SVN/hooks/pre-commit
        testing
        

        即使环境为空,这显然与 svn 钩子的运行方式相匹配.

        Even with an empty environment, which apparently matches how svn hooks are run.

        [phd@phabricator ~]$ env -i /var/repo/SVN/hooks/pre-commit
        testing
        

        • 脚本的shebang似乎是正确的:
        • [phd@phabricator ~]$ which sh
          /bin/sh
          [phd@phabricator ~]$ ls -la /bin/sh
          lrwxrwxrwx. 1 root root 4 Aug 18 09:37 /bin/sh -> bash
          [phd@phabricator ~]$ which bash
          /bin/bash
          

          • 如果钩子被删除,我可以提交代码.
          • 我可以结帐代码.
          • 更新

            根据#svn IRC 频道中的讨论,我尝试了以下操作:

            Based on a discussion in the #svn IRC channel, I tried the following:

            sudo svn mkdir file:///var/repo/SVN/TestFolder -m "Add test folder"
            
            svn: E165001: Commit blocked by pre-commit hook (exit code 1) with output:
            testing
            

            所以这意味着钩子可以工作并且可能根本没有错.仍然不确定问题是什么,所以不能完全排除钩子(可能是钩子大部分都很好,但需要改变一些东西才能使用这个配置).不过,问题似乎出在其他地方.欢迎任何帮助.

            So this implies that the hook can work and may not be at fault at all. Still not sure what the problem is though, so can't totally rule out the hook (could be the hook is mostly fine, but something needs to be changed for it to work with this configuration). It seems likely that the problem lies elsewhere though. Any help is welcome.

            推荐答案

            我在Centos6.5上部署了svn server,在Win7上使用客户端TortoiseSVN1.8.10.第一次添加预提交钩子脚本时,客户端会在提交时弹出消息提交被预提交钩子阻止(退出代码255)且没有输出".我刚刚通过以下操作解决了我的问题:

            I have svn server deployed on Centos6.5, and use client TortoiseSVN1.8.10 on Win7. When first time the pre-commit hook script is added, the message "Commit blocked by pre-commit hook (exit code 255) with no output" pops up in client when commit. I just solved it in my case with following action:

            $ cd/data/svn/hooks/

            $ cd /data/svn/hooks/

            $ chmod +x ./预提交

            $ chmod +x ./pre-commit

            这篇关于svn:E165001:提交被预提交钩子(退出代码 255)阻止,没有输出.如何解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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