Merge branch 'stable-2.16' into stable-3.0

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

Change-Id: I1eb449cda2fa0d95029271f29a7b5c0e161edb97
This commit is contained in:
David Pursehouse
2019-11-12 13:36:34 -08:00
6 changed files with 25 additions and 9 deletions

View File

@@ -1053,8 +1053,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

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

View File

@@ -24,6 +24,7 @@ import com.google.gerrit.extensions.registration.Extension;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.reviewdb.client.Account;
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.Project;
import com.google.gerrit.reviewdb.client.RefNames;
@@ -81,6 +82,7 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
Branch.NameKey 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 Branch.NameKey destBranch,
final Change.Id changeId,
final PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
@@ -252,11 +255,12 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
Branch.NameKey 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,
Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {
@@ -337,6 +342,7 @@ public class MergeValidators {
CodeReviewCommit commit,
ProjectState destProject,
Branch.NameKey destBranch,
Change.Id changeId,
PatchSet.Id patchSetId,
IdentifiedUser caller)
throws MergeValidationException {

View File

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

View File

@@ -2280,15 +2280,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);
},
/**