svn - 无法从 svn 预提交 Hook 生成输出

标签 svn pre-commit-hook

我有一个托管 svn(版本 1.6.11 (r934486))存储库的 centos6 linux 服务器,可通过 Apache 通过 DAV 访问。我正在使用 windows tortoise-svn 客户端 1.7.12 来访问 repo。

我有一个非常简单的测试预提交钩子(Hook),它总是会失败。

echo "this is a test"
exit 1

尝试提交失败
Sending content: D:\code\foo\test.c  
Error: Commit failed (details follow):  
Error: Commit blocked by pre-commit hook (exit code 1) with no output.  
Completed!:   

我期待在我的客户端上看到“这是一个测试”,但是我得到了 pre-commit 钩子(Hook)退出而没有输出。 hooks/pre-commit 是可执行的,并且在 linux 服务器上手动运行时会回显预期的输出。

关于我缺少什么的任何指示?

最佳答案

只有打印到 stderr 的输出才会中继到客户端。因此,以下更改应该使您的测试 Hook 工作:

echo "this is a test" >&2
exit 1

作为引用,这里是来自 Subversion book 的相关报价。 :

"If the pre-commit hook program returns a nonzero exit value, the commit is aborted, the commit transaction is removed, and anything printed to stderr is marshalled back to the client."

关于svn - 无法从 svn 预提交 Hook 生成输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16751653/

相关文章:

java - Subversion 中提取接口(interface)重构的最佳体现

svn - 传递给 SVN --diff3-cmd 的参数是什么?

svn - 向现有项目添加版本控制

svn - 如何以最佳性能实现SVN预提交 Hook ?

Flash 源代码控制 - 最佳实践

SVN (Tortoise) 不再在提交时检测新添加的文件(自动忽略)

linux - 为什么从 SVN 事务读取而不是从 SVN 修订版读取时 iconv 退出并出错?

git - 如何将 clang-formatting 添加到预提交 Hook ?

svn - Subversion 标记和安全性

Prettier 使用 pre-commit(.com) 不会重新暂存更改