如何防止有人推多个头?

发布于 2024-11-29 14:37:51 字数 80 浏览 0 评论 0原文

我的一些同事使用 --force 开关推动多个头,因为它们没有正确合并。

有什么方法可以防止这种情况吗?

I have colleagues who push multiple heads by using the --force switch because they haven't merged properly.

Are there any ways to prevent this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

怼怹恏 2024-12-06 14:37:51

您可以使用服务器端的 pretxnchangegroup 挂钩来完成此操作。

以下是一些示例: http:// /www.softwareprojects.com/resources/programming/t-mercurial-hook-forbid-2-heads-1910.html

所有这些钩子正在做的是确保在应用了changegroup,仍然只有一个头(或者如果你想变得更奇特的话,每个分支只有一个头)。

You can do this with a pretxnchangegroup hook on the server side.

Here are a few examples: http://www.softwareprojects.com/resources/programming/t-mercurial-hook-forbid-2-heads-1910.html

All those hooks are doing is making sure that after the changegroup is applied that there's still only one head (or only one per branch if you want to get fancy).

时光倒影 2024-12-06 14:37:51

告诉他们不应该这样做,并通过您控制的存储库上的挂钩强制执行工作流程。

在工作中,我们将其限制为一个头/分支。本质上用以下内容替换 forbid_2head.sh :

#!/bin/bash

# Ensure only one head per branch in hg repository
for BRANCH in `hg branches -qa`
do
    COUNT=`hg heads -q $BRANCH | wc -l`
    if [ "$COUNT" -ne "1" ] ; then
       echo "Error: Trying to push more than one head to branch $BRANCH."
       exit 1
    fi
done
exit 0

Tell them they shouldn't do it, and enforce the workflow with hooks on a repository you control.

At work, we restrict it to one head / branch. Essentially replace forbid_2head.sh with this:

#!/bin/bash

# Ensure only one head per branch in hg repository
for BRANCH in `hg branches -qa`
do
    COUNT=`hg heads -q $BRANCH | wc -l`
    if [ "$COUNT" -ne "1" ] ; then
       echo "Error: Trying to push more than one head to branch $BRANCH."
       exit 1
    fi
done
exit 0
森林很绿却致人迷途 2024-12-06 14:37:51

这是来自顶尖熟练开发人员的最佳http:// /hg.python.org/hooks/file/default/checkheads.py

访问http://hg.python.org/hooks/file/default/ 查看另一个有用的钩子列表。

This is the best from top proficient developers: http://hg.python.org/hooks/file/default/checkheads.py

Visit http://hg.python.org/hooks/file/default/ for list of another useful hooks.

我们的影子 2024-12-06 14:37:51

您可以撤销他们对他们正在--forceing的存储库的推送权限,并让他们推送到不同的服务器,或者通过补丁提交更改。

You could revoke their push rights to the repository that they are --forceing to, and make them push to a different server, or submit changes via patch.

情泪▽动烟 2024-12-06 14:37:51

首先,我会告诉开发人员,不允许使用 --force 推送。

我还会使用上面规定的服务器端挂钩解决方案,并在挂钩中向每个人添加一封电子邮件,说明谁试图将多个头推入中央存储库[然后格式化他的硬盘;)]

First off, I'd tell developers that a --force push is not allowed.

I'd also use the server side hook solution as prescribed above, and in the hook add an email to everyone stating WHO tried to push multiple heads into the central repo [and then format his hard drive ;)]

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