我已经做了一段时间了,但我似乎不能让它工作。
根据Kallithea文档:
To add another custom hook simply fill in the first textbox with <name>.<hook_type> and the second with the hook path. Example hooks can be found in kallithea.lib.hooks.
因此,我的第一个尝试是向hooks.py添加一个新方法。基本上,为了测试钩子,我想阻止所有推送到repo。因此,我将使用pretxnchangegroup并返回非0非假值作为Mercurial文档状态
A hook that executes successfully must exit with a status of zero if external, or return boolean “false” if in-process. Failure is indicated with a non-zero exit status from an external hook, or an in-process hook returning boolean “true”. If an in-process hook raises an exception, the hook is considered to have failed.
所以我这样做了:
def myhook(ui, repo, **kwargs): return True
我在Kallithea钩子选项中将钩子添加到GUI中:
pretxnchangegroup <=> python:kallithea.lib.hooks.myhook
但是,由于某些原因找不到该方法,因此此操作失败
abort: pretxnchangegroup hook is invalid ("kallithea.lib.hooks.myhook" is not defined)
所以我试着把它放到另一个文件中(和hooks.py放在同一个'lib‘文件夹中)。创建了一个名为canpush.py的文件,并在其中添加了相同的方法。我更改了钩子路径以指向新的文件名:
pretxnchangegroup <=> python:kallithea.lib.hooks.myhook
但是钩子不会触发,我可以毫无问题地推送到我的repo。我计划在未来改变实际的钩子实现,推送将被允许,但首先我需要使用Kallithea获得任何钩子函数。
我在这里做错了什么?
此外,如果有人知道如何在Kallithea中使用个人存储库的hgrc设置,那么举个例子就好了。原始问题here。
发布于 2016-05-24 16:23:00
回答我自己的问题,但只是作为参考。
事实证明,设置是正常的,但在绝望的行为中,我决定重启kallithea守护进程(在文档中找不到),基本上是在想“可能会出什么问题”-这就起到了作用!
我猜在启动过程中,程序会被编译/缓存,钩子定义的方法也会被找到并运行起来(如果有人能更好地解释kallithea重启会发生什么,请分享)
所以请记住,每次更改钩子文件后,必须重新启动kallithea守护进程才能使钩子生效。
sudo service kallithea restart
发布于 2019-05-18 01:56:39
在阅读kallithea文档时,我还不清楚的是,这些钩子是mercurial钩子,它们并不是什么kallithea/rhodecode,它一直都是mercurial钩子。
这意味着关于如何编写的最好的文档来源是类似于http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html的东西
https://stackoverflow.com/questions/37391559
复制相似问题