commit | 6c215337b4e612d3a40ce14a1a266677d580aa5e | [log] [tgz] |
---|---|---|
author | Edwin Kempin <ekempin@google.com> | Tue Nov 22 08:06:34 2022 +0100 |
committer | Edwin Kempin <ekempin@google.com> | Thu Nov 24 14:23:02 2022 +0100 |
tree | f2814066fea9760b34c6fd307119a8a7d6f15ba8 | |
parent | 0e5417ad2f24b40e03bb6c4d45b83fefc307d627 [diff] |
Highlight matching atoms of copy conditions in change messages When a new patch set is created and approvals are copied to the new patch set or if approvals are dropped (because they cannot be copied to the new patch set) Gerrit posts a change message to inform about the copied and outdated votes. For each copied/outdated vote the change message includes the corresponding copy condition, so that users can check why a vote matched or didn't match the copy condition. Understanding why a vote matched or didn't match the copy condition could be easier though if the passing and failing atoms in the copy condition would be highlighted. E.g. for expressions of submit requirements we already have such highlighting (passing atoms are underlined in green, failing atoms are underlined in red). It would be nice to have the same highlighting for copy conditions, but it's not easily doable. For the expressions of the submit requirements the highlighting is done in the web frontend. This requires the web frontend to know about the expression and the passing and failing atoms, which means that the backend must have an API to return this data. Adding such an API for copy conditions is not easy, since they are embedded in change messages which are plain strings. In addition the backend has only the current copy condition available and in restrospect it can't tell how the copy condition looked like at the moment when the copy evaluation for a certain approval was done. That's why for highlighting atoms in copy conditions we take a different approach. The change message with the copy conditions is generated at the moment when the copy evaluation is done. At this moment we can check which atoms of the copy conditions are passing/failing. We can then use this information to highlight the passing atoms in the change message. The change message is a plain string, but Markdown formatting is supported. We make use of this and use Markdown syntax to print passing atoms in bold. This is not the same formatting as for expressions of submit requirements, but it's the best we can do with Markdown. Markdown does neither support underlining text nor colored text (this is only possible with HTML snippets but those are not supported in change messages). This approach can be implemented with little effort and still allows us to highlight which atoms of a copy condition are passing. To implement this we compute the passing/failing atoms of the copy condition at the moment when the copy evaluation in ApprovalCopier is done. To pass this information to the caller we change the type for the copied/outdated approvals in ApprovalCopier.Result from PatchSetApproval to a new ApprovalData type that contains the PatchSetApproval and the passing and failing atoms (for consistency the method names for getting the passing/failing atoms are kept the same as for SubmitRequirementExpressionResult). ApprovalsUtil gets the copied/outdated approvals as input to format the change message with copied/dropped votes. In addition to the copied/outdated approvals it now has the passing and failing atoms available for each approval, so that it can format the passing atoms in bold (using Markdown syntax). So far approvals with the same label had been grouped as one line in the change message (since they have the same copy condition), e.g.: Copied Votes: * Code-Review-2, Code-Review+2 (copy condition: "is:MIN OR is:MAX") Now we need to split those into multiple lines if the passing atoms differ, so that in every line we can higlight different atoms: Copied Votes: * Code-Review-2 (copy condition: "**is:MIN** OR is:MAX") * Code-Review+2 (copy condition: "is:MIN OR **is:MAX**") If approvals for the same label have the same passing atoms they are still grouped together as one line, e.g.: Copied Votes: * Code-Review-1, Code-Review+1 (copy condition: "is:MIN OR **changekind:TRIVIAL_REBASE**") Bug: Google b/240377462 Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: I7b42f350f9d79b1dc3cac62aeac7d7c7f8699456 Release-Notes: Matching atoms in copy conditions that are posted as change messages are highlighted in bold now
Gerrit is a code review and project management tool for Git based projects.
Gerrit makes reviews easier by showing changes in a side-by-side display, and allowing inline comments to be added by any reviewer.
Gerrit simplifies Git based project maintainership by permitting any authorized user to submit changes to the master Git repository, rather than requiring all approved changes to be merged in by hand by the project maintainer.
For information about how to install and use Gerrit, refer to the documentation.
Our canonical Git repository is located on googlesource.com. There is a mirror of the repository on Github.
Please report bugs on the issue tracker.
Gerrit is the work of hundreds of contributors. We appreciate your help!
Please read the contribution guidelines.
Note that we do not accept Pull Requests via the Github mirror.
The Developer Mailing list is repo-discuss on Google Groups.
Gerrit is provided under the Apache License 2.0.
Install Bazel and run the following:
git clone --recurse-submodules https://gerrit.googlesource.com/gerrit cd gerrit && bazel build release
The instruction how to configure GerritForge/BinTray repositories is here
On Debian/Ubuntu run:
apt-get update && apt-get install gerrit=<version>-<release>
NOTE: release is a counter that starts with 1 and indicates the number of packages that have been released with the same version of the software.
On CentOS/RedHat run:
yum clean all && yum install gerrit-<version>[-<release>]
On Fedora run:
dnf clean all && dnf install gerrit-<version>[-<release>]
Docker images of Gerrit are available on DockerHub
To run a CentOS 8 based Gerrit image:
docker run -p 8080:8080 gerritcodereview/gerrit[:version]-centos8
To run a Ubuntu 20.04 based Gerrit image:
docker run -p 8080:8080 gerritcodereview/gerrit[:version]-ubuntu20
NOTE: release is optional. Last released package of the version is installed if the release number is omitted.