Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Avoid browser caching for diff on edit patch
  MergeValidationListener: Include the change Id in onPreMerge
  Upgrade jackson-core to 2.10.1

Change-Id: Ie35736b6dcfd4f85c96f87d705e1257ea801a355
This commit is contained in:
David Pursehouse
2019-11-12 14:13:04 -08:00
6 changed files with 26 additions and 9 deletions

View File

@@ -1024,8 +1024,8 @@ maven_jar(
maven_jar(
name = "jackson-core",
artifact = "com.fasterxml.jackson.core:jackson-core:2.10.0",
sha1 = "4e2c5fa04648ec9772c63e2101c53af6504e624e",
artifact = "com.fasterxml.jackson.core:jackson-core:2.10.1",
sha1 = "2c8b5e26ba40e5f91eb37a24075a2028b402c5f9",
)
TESTCONTAINERS_VERSION = "1.12.3"

View File

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

View File

@@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.BranchNameKey;
import com.google.gerrit.entities.Change;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.RefNames;
@@ -81,6 +82,7 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
BranchNameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
@@ -92,7 +94,7 @@ public class MergeValidators {
groupValidatorFactory.create());
for (MergeValidationListener validator : validators) {
validator.onPreMerge(repo, commit, destProject, destBranch, patchSetId, caller);
validator.onPreMerge(repo, commit, destProject, destBranch, changeId, patchSetId, caller);
}
}
@@ -157,6 +159,7 @@ public class MergeValidators {
final CodeReviewCommit commit,
final ProjectState destProject,
final BranchNameKey destBranch,
final Change.Id changeId,
final PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
@@ -252,11 +255,12 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
BranchNameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
mergeValidationListeners.runEach(
l -> l.onPreMerge(repo, commit, destProject, destBranch, patchSetId, caller),
l -> l.onPreMerge(repo, commit, destProject, destBranch, changeId, patchSetId, caller),
MergeValidationException.class);
}
}
@@ -286,6 +290,7 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
BranchNameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
@@ -336,6 +341,7 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
BranchNameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {

View File

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

View File

@@ -1944,15 +1944,23 @@
params.base = basePatchNum;
}
const endpoint = `/files/${encodeURIComponent(path)}/diff`;
return this._getChangeURLAndFetch({
const req = {
changeNum,
endpoint,
patchNum,
errFn: opt_errFn,
params,
anonymizedEndpoint: '/files/*/diff',
});
};
// Invalidate the cache if its edit patch to make sure we always get latest.
if (patchNum === this.EDIT_NAME) {
if (!req.fetchOptions) req.fetchOptions = {};
if (!req.fetchOptions.headers) req.fetchOptions.headers = new Headers();
req.fetchOptions.headers.append('Cache-Control', 'no-cache');
}
return this._getChangeURLAndFetch(req);
},
/**