CommitValidators: Add a hint for MULTIPLE_CHANGE_ID error

Release-Notes: skip
Google-Bug-Id: b/346509265
Change-Id: I945501983538b4ebbb5c5b7b488f587ae7f2e85d
diff --git a/java/com/google/gerrit/server/git/validators/CommitValidators.java b/java/com/google/gerrit/server/git/validators/CommitValidators.java
index 5c7d524..2311240 100644
--- a/java/com/google/gerrit/server/git/validators/CommitValidators.java
+++ b/java/com/google/gerrit/server/git/validators/CommitValidators.java
@@ -356,6 +356,7 @@
           throw new CommitValidationException(MISSING_CHANGE_ID_MSG, messages);
         }
       } else if (idList.size() > 1) {
+        messages.add(getMultipleChangeIdsErrorMsg(idList));
         throw new CommitValidationException(MULTIPLE_CHANGE_ID_MSG, messages);
       } else {
         String v = idList.get(0).trim();
@@ -391,6 +392,24 @@
           ValidationMessage.Type.ERROR);
     }
 
+    private CommitValidationMessage getMultipleChangeIdsErrorMsg(List<String> idList) {
+      return new CommitValidationMessage(
+          MULTIPLE_CHANGE_ID_MSG
+              + "\n"
+              + "\nHint: the following Change-Ids were found:\n"
+              + idList.stream()
+                  .map(
+                      id ->
+                          "* "
+                              + id
+                              + " ["
+                              + (CHANGE_ID.matcher(id.trim()).matches() ? "VALID" : "INVALID")
+                              + "]")
+                  .collect(Collectors.joining("\n"))
+              + "\n",
+          ValidationMessage.Type.ERROR);
+    }
+
     private String getCommitMessageHookInstallationHint() {
       if (installCommitMsgHookCommand != null) {
         return installCommitMsgHookCommand;