流产后,如何执行行动?
我正在使用Mercurial的前签名挂钩将一些信息写入存储库中的文件。
如果提交失败/中止(例如用户未输入提交消息时),我希望将文件删除。
我考虑过使用邮政挂钩,但是当我将以下代码放在后签名中时,它似乎并没有为中止的提交而运行: post-commit =导出| GREP“导出Hg _”
是否有更好的方法来完成此操作的方法,而不是创建用户别名(cmt
),它检查了hg commit
和然后使用它而不是commit
命令?我问的原因是B/C我正在尝试编写一些触发器来帮助我的编码团队,但不想强迫他们使用别名代替标准命令(不能真正轻松地执行此操作; 't超载commit
作为别名,它似乎或将被卡在无限循环中):
[hook]
pre-commit = echo "some info to a file" > info.out ;
[alias]
cmt = ! $HG commit "${HG_ARGS[@]:4}" ; if (($?)); then rm info.out ; fi
I'm using mercurial's pre-commit hook to write out some information to a file inside the repo.
If the commit fails/aborts (like when the user doesn't enter a commit message), I want the file to be removed.
I considered using the post-commit hook, but when I put the following code in the post-commit hook, it doesn't appear to run for an aborted commit:post-commit = export | grep "export HG_"
Is there a better way to do this than to create a user alias (cmt
)that checks the exit result of the hg commit
and then use that instead of the commit
command? The reason I ask is b/c I'm trying to write some triggers to help my coding team, but don't want to force them to use an alias in place of the standard commands (can't really enforce this easily; can't overload the commit
either as an alias it seems or will be stuck in an infinite loop):
[hook]
pre-commit = echo "some info to a file" > info.out ;
[alias]
cmt = ! $HG commit "${HG_ARGS[@]:4}" ; if (($?)); then rm info.out ; fi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用:
在创建变更集之后、提交事务之前调用此挂钩。
Could you use:
This hook is called after a changeset has been created, but before the transaction is committed.