com.google.gerrit.server.git.validators.CommitValidationListener warning messages

62 views
Skip to first unread message

Loki

unread,
Nov 13, 2019, 7:31:29 AM11/13/19
to Repo and Gerrit Discussion
Hi *,

I try to send non errors to committers by implementing com.google.gerrit.server.git.validators.CommitValidationListener#onCommitReceived method.

So I tried to fill the returning list with message like this

new CommitValidationMessage("Your message is longer then 7000 chars, this will become an error next week", false)

but the message is not shown. This could be useful to inform committers about e.g. external analysis results known from e.g. github like

new CommitValidationMessage("This project references the dependency to com.some.vulnerable:artifact:1.2.3 - CVE-2022-10234", false)

Can you help me, how to implement onCommitReceived and send non errors to an user?

David Pursehouse

unread,
Nov 13, 2019, 11:28:19 AM11/13/19
to Loki, Repo and Gerrit Discussion
From what I can see in the code snippets above, that should work, but without surrounding context it's difficult to say for sure.   You could have a look at the CommitMessageLengthValidation class in the commit-message-length-validator plugin; this is doing the same thing and you could compare the implementations.

One thing you might have forgotten to do is bind your implementation class to the CommitValidationListener interface.  In the plugin I mentioned above it's done with the @Listen annotation but you can also do an explicit binding if your plugin has a module class.

If it's still not working, please also mention which gerrit version you're using so that we can double check it.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/baffc152-e6f8-4407-9f1a-923df5535657%40googlegroups.com.

Loki

unread,
Nov 28, 2019, 12:31:53 PM11/28/19
to Repo and Gerrit Discussion
My implementation of CommitValidationListener is annotated with @Listen and works fine in cases where CommitValidationMessages with isError=true are returned

$ git push origin HEAD:refs/for/master
...
remote: Resolving deltas: 100% (2/2)
remote: Processing changes: refs: 1, done
remote: error: commit 7fffc41: Line is too long ...
remote: commit 7fffc41: test ok

When I repair the long line

$ git push origin HEAD:refs/for/master
...
remote: Resolving deltas: 100% (2/2)
remote: Processing changes: new: 1, done
remote:
remote: New Changes:
remote: https://.../#/c/..../+/112367 A valid change
remote:

The line "remote: commit 7fffc41: test ok" was not shown

We use gerrit 2.15.15

On Wednesday, November 13, 2019 at 5:28:19 PM UTC+1, David Pursehouse wrote:
On Wed, Nov 13, 2019 at 4:31 AM Loki <sto...@gmail.com> wrote:
Hi *,

I try to send non errors to committers by implementing com.google.gerrit.server.git.validators.CommitValidationListener#onCommitReceived method.

So I tried to fill the returning list with message like this

new CommitValidationMessage("Your message is longer then 7000 chars, this will become an error next week", false)

but the message is not shown. This could be useful to inform committers about e.g. external analysis results known from e.g. github like

new CommitValidationMessage("This project references the dependency to com.some.vulnerable:artifact:1.2.3 - CVE-2022-10234", false)

Can you help me, how to implement onCommitReceived and send non errors to an user?

From what I can see in the code snippets above, that should work, but without surrounding context it's difficult to say for sure.   You could have a look at the CommitMessageLengthValidation class in the commit-message-length-validator plugin; this is doing the same thing and you could compare the implementations.

One thing you might have forgotten to do is bind your implementation class to the CommitValidationListener interface.  In the plugin I mentioned above it's done with the @Listen annotation but you can also do an explicit binding if your plugin has a module class.

If it's still not working, please also mention which gerrit version you're using so that we can double check it.

--
--
To unsubscribe, email repo-d...@googlegroups.com

More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-d...@googlegroups.com.

Loki

unread,
Dec 2, 2019, 5:54:33 AM12/2/19
to Repo and Gerrit Discussion
I'll try it with 2.16. again
Reply all
Reply to author
Forward
0 new messages