MergeValidationListener: Include the change Id in onPreMerge

Bug: Issue 11905
Change-Id: Ib0a65d12991b768f169cfe7fd562dcf8defc4d74
This commit is contained in:
David Pursehouse
2019-11-12 09:40:48 -08:00
parent 8f5013449f
commit 593a500705
4 changed files with 12 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.git.validators;
import com.google.gerrit.extensions.annotations.ExtensionPoint; import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.CodeReviewCommit;
@@ -45,6 +46,7 @@ public interface MergeValidationListener {
CodeReviewCommit commit, CodeReviewCommit commit,
ProjectState destProject, ProjectState destProject,
Branch.NameKey destBranch, Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId, PatchSet.Id patchSetId,
IdentifiedUser caller) IdentifiedUser caller)
throws MergeValidationException; throws MergeValidationException;

View File

@@ -23,6 +23,7 @@ import com.google.gerrit.extensions.registration.Extension;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RefNames;
@@ -83,6 +84,7 @@ public class MergeValidators {
CodeReviewCommit commit, CodeReviewCommit commit,
ProjectState destProject, ProjectState destProject,
Branch.NameKey destBranch, Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId, PatchSet.Id patchSetId,
IdentifiedUser caller) IdentifiedUser caller)
throws MergeValidationException { throws MergeValidationException {
@@ -94,7 +96,7 @@ public class MergeValidators {
groupValidatorFactory.create()); groupValidatorFactory.create());
for (MergeValidationListener validator : validators) { for (MergeValidationListener validator : validators) {
validator.onPreMerge(repo, commit, destProject, destBranch, patchSetId, caller); validator.onPreMerge(repo, commit, destProject, destBranch, changeId, patchSetId, caller);
} }
} }
@@ -156,6 +158,7 @@ public class MergeValidators {
final CodeReviewCommit commit, final CodeReviewCommit commit,
final ProjectState destProject, final ProjectState destProject,
final Branch.NameKey destBranch, final Branch.NameKey destBranch,
final Change.Id changeId,
final PatchSet.Id patchSetId, final PatchSet.Id patchSetId,
IdentifiedUser caller) IdentifiedUser caller)
throws MergeValidationException { throws MergeValidationException {
@@ -251,11 +254,12 @@ public class MergeValidators {
CodeReviewCommit commit, CodeReviewCommit commit,
ProjectState destProject, ProjectState destProject,
Branch.NameKey destBranch, Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId, PatchSet.Id patchSetId,
IdentifiedUser caller) IdentifiedUser caller)
throws MergeValidationException { throws MergeValidationException {
mergeValidationListeners.runEach( mergeValidationListeners.runEach(
l -> l.onPreMerge(repo, commit, destProject, destBranch, patchSetId, caller), l -> l.onPreMerge(repo, commit, destProject, destBranch, changeId, patchSetId, caller),
MergeValidationException.class); MergeValidationException.class);
} }
} }
@@ -288,6 +292,7 @@ public class MergeValidators {
CodeReviewCommit commit, CodeReviewCommit commit,
ProjectState destProject, ProjectState destProject,
Branch.NameKey destBranch, Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId, PatchSet.Id patchSetId,
IdentifiedUser caller) IdentifiedUser caller)
throws MergeValidationException { throws MergeValidationException {
@@ -339,6 +344,7 @@ public class MergeValidators {
CodeReviewCommit commit, CodeReviewCommit commit,
ProjectState destProject, ProjectState destProject,
Branch.NameKey destBranch, Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId, PatchSet.Id patchSetId,
IdentifiedUser caller) IdentifiedUser caller)
throws MergeValidationException { throws MergeValidationException {

View File

@@ -846,7 +846,7 @@ public class MergeOp implements AutoCloseable {
MergeValidators mergeValidators = mergeValidatorsFactory.create(); MergeValidators mergeValidators = mergeValidatorsFactory.create();
try { try {
mergeValidators.validatePreMerge( mergeValidators.validatePreMerge(
or.repo, commit, or.project, destBranch, ps.getId(), caller); or.repo, commit, or.project, destBranch, changeId, ps.getId(), caller);
} catch (MergeValidationException mve) { } catch (MergeValidationException mve) {
commitStatus.problem(changeId, mve.getMessage()); commitStatus.problem(changeId, mve.getMessage());
continue; continue;