关于 "Gerrit Change Number" 的官方文档

Official documentation about "Gerrit Change Number"

这是我另一个问题的后续问题:

我现在了解到 Gerrit url 中嵌入的小整数称为“Gerrit 更改编号”,有时称为“数字更改编号” ”。比如下面Gerrit中的数字68url

http://gerrithost:8080/68

这个数字在理解 Gerrit 工作流程方面起着重要作用,但关于它的讨论并不多。我什至有一种感觉,它可能已被弃用(因为 Change-Id —— 以字符 "I" 为前缀的长散列字符串 —— 也唯一标识一个 gerrit 改变)

Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b

在哪里可以找到有关 Gerrit 更改编号的更多讨论?它真的被弃用了吗?如果是,那是否意味着存在不使用数字的工作流程? (但是 Gerrit URL 是如何构建的?)

我在这个页面上找到了这个讨论 (Gerrit User Guide)。表示数字在工作流程中的重要性。

When a commit is pushed for review, Gerrit stores it in a staging area which is a branch in the special refs/changes/ namespace. A change ref has the format refs/changes/XX/YYYY/ZZ where YYYY is the numeric change number, ZZ is the patch set number and XX is the last two digits of the numeric change number, e.g. refs/changes/20/884120/1. Understanding the format of this ref is not required for working with Gerrit.

Gerrit 更改编号未弃用。这是在浏览器中访问 Gerrit 更改的方式 URL (https://GERRIT-SERVER/GERRIT-CHANGE-NUMBER).

Change-Id 也识别更改,但它是后来创建的以解决特定问题:识别属于同一评论的提交(补丁集)。例如,当需要修改更改时,可以上传第二个提交来解决报告的问题。 Gerrit 允许将这 2 个提交附加到相同的更改,并依赖于提交消息底部的 Change-Id 行来执行此操作。有了这个 Change-Id,Gerrit 可以自动将更改的新版本关联回其原始审核,甚至跨越 cherry-picks 和变基。

详细了解 Change-Id here

更改号码和 Change-ID 有不同的用途。

来自Gerrit Docs on Change-Ids...

Gerrit needs to identify commits that belong to the same review. For instance, when a change needs to be modified, a second commit can be uploaded to address the reported issues. Gerrit allows attaching those 2 commits to the same change, and relies upon a Change-Id line at the bottom of a commit message to do so. With this Change-Id, Gerrit can automatically associate a new version of a change back to its original review, even across cherry-picks and rebases.

Change-ID 是一个校验和,用于在审查过程中通过变基、修改和其他重写提交的方式识别相同的更改。这是关键:Git 不会重写提交。 Git 创建新提交并假装一直都是这样。 Gerrit 需要一种方法来知道这些新提交实际上与您提出的提交相关评论。

更多来自 User Guide...

If a commit that has a Change-Id in its commit message is pushed for review, Gerrit checks if a change with this Change-Id already exists for this project and target branch, and if yes, Gerrit creates a new patch set for this change. If not, a new change with the given Change-Id is created.

If a commit without Change-Id is pushed for review, Gerrit creates a new change and generates a Change-Id for it.

Amending and rebasing a commit preserves the Change-Id so that the new commit automatically becomes a new patch set of the existing change, when it is pushed for review.

查看它的一种方法是更改​​编号是更改的人类可读标识符。 Change-ID 是 Gerrit 的簿记。 Change-ID 仅对用户可见,因为 Git 除了将其放入提交消息中之外,Gerrit 无法存储有关提交的元数据。

更改号唯一标识一次更改。它是更改条目的唯一值。除了 urls 和 refs,它还可以用于 Gerrit 查询和 REST API。

ssh -p 29418 $user@$gerrithost gerrit query change:884120
curl --digest --user $user:$httpassword $gerrithost/gerrit/a/changes/884120

我期待这样的讨论。我相信以下断言是正确的,但我需要确认。 (这就是为什么我首先要寻找文档的原因)。请帮助我。

  1. Gerrit 更改号(又名数字更改号),如 Gerrit Change-Id,唯一标识一个 "change under review",它可能有多个补丁集,因为 code-review循环。与 Gerrit Change-Id 不同,它是一个小整数,可能更易于人类用户使用。 (相比之下,Gerrit Change-Id 是一个长哈希字符串,前面有字符 "I")
  2. Gerrit 更改编号用于参考文献(请参阅开头问题中引用的部分)以及 URL 和查询以及 REST API(请参阅 ElpieKay 的回答)
  3. Gerrit 更改编号对于服务器是唯一的。托管在同一台服务器上的多个项目共享相同的编号 space。
  4. Gerrit 更改编号 通常 随着新更改 提交审查 到 Gerrit 服务器而单调递增。但是请注意,由于不同的更改可能需要不同的时间来完成代码审查,因此无法保证更改将按顺序应用到 master 分支(或完全应用)。像这样 较大 数字更改编号 Y 的更改可以在主分支上生效 另一个具有较小数字更改编号的更改之前X。换句话说,在master分支上,当有两个变化分别为X和Y,并且X不保证X happens-beforeY。