流产后,如何执行行动?

发布于 2025-01-19 03:45:36 字数 575 浏览 3 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我也只是我 2025-01-26 03:45:36

您可以使用:

[hook]
pretxncommit = echo "some info to a file" > info.out ;

在创建变更集之后、提交事务之前调用此挂钩。

Could you use:

[hook]
pretxncommit = echo "some info to a file" > info.out ;

This hook is called after a changeset has been created, but before the transaction is committed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文