Merge branch 'stable-3.1'

* stable-3.1:
  Set version to 3.1.1-SNAPSHOT
  Set version to 3.1.0
  Upgrade JGit to latest master
  Upgrade gitiles-servlet and blame-cache to 0.3-6
  Add sshd-common to lib/nongoogle_test.sh
  Increase 'execution.defaultThreadPoolSize' default and min to 2
  Upgrade gitiles-servlet and blame-cache to 0.2-11
  Fix formatting of submission IDs
  LazyPostReceiveHookChain: Simplify check for pack size
  Update highlight.js
  ChangeNotesParser: Skip parsing meta data of deleted patch sets
  Add a --header-box-shadow theme css variable
  Don't allow "show 2 more" reviewers
  Bazel: Expedite the LC process
  Update Jgit to latest master revision
  Move tooltip to below the button for change detail actions
  LazyPostReceiveHookChain: Catch IllegalStateException on ReceivePack.getPackSize

Change-Id: I8e118de48a692ef60171d4f4d26f69bafb330c70
This commit is contained in:
David Pursehouse
2019-11-15 00:17:36 -08:00
20 changed files with 474 additions and 202 deletions

View File

@@ -4095,7 +4095,8 @@ Default is 256.
The default size of the background execution thread pool in The default size of the background execution thread pool in
which miscellaneous tasks are handled. which miscellaneous tasks are handled.
+ +
Default is 1. Default and minimum is 2 so that a single, potentially longer executing
task (e.g. GC), is not blocking the entire execution.
[[execution.fanOutThreadPoolSize]]execution.fanOutThreadPoolSize:: [[execution.fanOutThreadPoolSize]]execution.fanOutThreadPoolSize::
+ +

135
WORKSPACE
View File

@@ -241,12 +241,6 @@ maven_jar(
sha1 = "1dcf1de382a0bf95a3d8b0849546c88bac1292c9", sha1 = "1dcf1de382a0bf95a3d8b0849546c88bac1292c9",
) )
maven_jar(
name = "j2objc",
artifact = "com.google.j2objc:j2objc-annotations:1.1",
sha1 = "ed28ded51a8b1c6b112568def5f4b455e6809019",
)
maven_jar( maven_jar(
name = "jsch", name = "jsch",
artifact = "com.jcraft:jsch:0.1.54", artifact = "com.jcraft:jsch:0.1.54",
@@ -729,7 +723,7 @@ maven_jar(
sha1 = "f7be08ec23c21485b9b5a1cf1654c2ec8c58168d", sha1 = "f7be08ec23c21485b9b5a1cf1654c2ec8c58168d",
) )
GITILES_VERS = "0.3-5" GITILES_VERS = "0.3-6"
GITILES_REPO = GERRIT GITILES_REPO = GERRIT
@@ -738,14 +732,14 @@ maven_jar(
artifact = "com.google.gitiles:blame-cache:" + GITILES_VERS, artifact = "com.google.gitiles:blame-cache:" + GITILES_VERS,
attach_source = False, attach_source = False,
repository = GITILES_REPO, repository = GITILES_REPO,
sha1 = "22d5e48827bd48b9e7b049bb9726ef017fda9eca", sha1 = "bd1ec86570b8a6e4b68c5af6311c8cd10aa3f295",
) )
maven_jar( maven_jar(
name = "gitiles-servlet", name = "gitiles-servlet",
artifact = "com.google.gitiles:gitiles-servlet:" + GITILES_VERS, artifact = "com.google.gitiles:gitiles-servlet:" + GITILES_VERS,
repository = GITILES_REPO, repository = GITILES_REPO,
sha1 = "061de6d5ef22be870300cc01a6fb205bb7782eae", sha1 = "98bf06ca9abc871beb3d6c01e6f053243d4e911a",
) )
# prettify must match the version used in Gitiles # prettify must match the version used in Gitiles
@@ -774,12 +768,6 @@ maven_jar(
sha1 = "198ea005f41219f038f4291f0b0e9f3259730e92", sha1 = "198ea005f41219f038f4291f0b0e9f3259730e92",
) )
maven_jar(
name = "dropwizard-core",
artifact = "io.dropwizard.metrics:metrics-core:4.1.1",
sha1 = "ebfafc716d9c3b6151dc7c2c09ce925a163a4f21",
)
# When updating Bouncy Castle, also update it in bazlets. # When updating Bouncy Castle, also update it in bazlets.
BC_VERS = "1.61" BC_VERS = "1.61"
@@ -801,38 +789,6 @@ maven_jar(
sha1 = "89bb3aa5b98b48e584eee2a7401b7682a46779b4", sha1 = "89bb3aa5b98b48e584eee2a7401b7682a46779b4",
) )
SSHD_VERS = "2.3.0"
maven_jar(
name = "sshd",
artifact = "org.apache.sshd:sshd-core:" + SSHD_VERS,
sha1 = "21aeea9deba96c9b81ea0935fa4fac61aa3cf646",
)
maven_jar(
name = "sshd-common",
artifact = "org.apache.sshd:sshd-common:" + SSHD_VERS,
sha1 = "8b6e3baaa0d35b547696965eef3e62477f5e74c9",
)
maven_jar(
name = "sshd-mina",
artifact = "org.apache.sshd:sshd-mina:" + SSHD_VERS,
sha1 = "55dc0830dfcbceba01f9460812ee454978a15fe8",
)
maven_jar(
name = "eddsa",
artifact = "net.i2p.crypto:eddsa:0.3.0",
sha1 = "1901c8d4d8bffb7d79027686cfb91e704217c3e1",
)
maven_jar(
name = "mina-core",
artifact = "org.apache.mina:mina-core:2.0.21",
sha1 = "e1a317689ecd438f54e863747e832f741ef8e092",
)
maven_jar( maven_jar(
name = "h2", name = "h2",
artifact = "com.h2database:h2:1.3.176", artifact = "com.h2database:h2:1.3.176",
@@ -861,20 +817,6 @@ maven_jar(
sha1 = "f5aa318bda4c6c8d688c9d00b90681dcd82ce636", sha1 = "f5aa318bda4c6c8d688c9d00b90681dcd82ce636",
) )
# elasticsearch-rest-client explicitly depends on this version
maven_jar(
name = "httpasyncclient",
artifact = "org.apache.httpcomponents:httpasyncclient:4.1.4",
sha1 = "f3a3240681faae3fa46b573a4c7e50cec9db0d86",
)
# elasticsearch-rest-client explicitly depends on this version
maven_jar(
name = "httpcore-nio",
artifact = "org.apache.httpcomponents:httpcore-nio:4.4.11",
sha1 = "7d0a97d01d39cff9aa3e6db81f21fddb2435f4e6",
)
# Test-only dependencies below. # Test-only dependencies below.
maven_jar( maven_jar(
@@ -971,25 +913,6 @@ maven_jar(
sha1 = "13e6148bfda7ae511f69ae7e5e3ea898bc9b0e33", sha1 = "13e6148bfda7ae511f69ae7e5e3ea898bc9b0e33",
) )
maven_jar(
name = "openid-consumer",
artifact = "org.openid4java:openid4java:1.0.0",
sha1 = "541091bb49f2c0d583544c5bb1e6df7612d31e3e",
)
maven_jar(
name = "nekohtml",
artifact = "net.sourceforge.nekohtml:nekohtml:1.9.10",
sha1 = "14052461031a7054aa094f5573792feb6686d3de",
)
maven_jar(
name = "xerces",
artifact = "xerces:xercesImpl:2.8.1",
attach_source = False,
sha1 = "25101e37ec0c907db6f0612cbf106ee519c1aef1",
)
maven_jar( maven_jar(
name = "commons-io", name = "commons-io",
artifact = "commons-io:commons-io:2.2", artifact = "commons-io:commons-io:2.2",
@@ -1002,58 +925,6 @@ maven_jar(
sha1 = "8e8c1d8fc6144405700dd8df3b177f2801ac5987", sha1 = "8e8c1d8fc6144405700dd8df3b177f2801ac5987",
) )
maven_jar(
name = "jruby",
artifact = "org.jruby:jruby-complete:9.1.17.0",
sha1 = "76716d529710fc03d1d429b43e3cedd4419f78d4",
)
# When upgrading elasticsearch-rest-client, also upgrade httpcore-nio
# and httpasyncclient as necessary.
maven_jar(
name = "elasticsearch-rest-client",
artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.4.2",
sha1 = "f48725523c0b3402f869214433602f8d3f4c737c",
)
maven_jar(
name = "jackson-core",
artifact = "com.fasterxml.jackson.core:jackson-core:2.10.1",
sha1 = "2c8b5e26ba40e5f91eb37a24075a2028b402c5f9",
)
TESTCONTAINERS_VERSION = "1.12.3"
maven_jar(
name = "testcontainers",
artifact = "org.testcontainers:testcontainers:" + TESTCONTAINERS_VERSION,
sha1 = "e424a4549640e120acceac641ac909fcda58bf62",
)
maven_jar(
name = "testcontainers-elasticsearch",
artifact = "org.testcontainers:elasticsearch:" + TESTCONTAINERS_VERSION,
sha1 = "c0796de5032070b8768ce78c78949b48f13c30db",
)
maven_jar(
name = "duct-tape",
artifact = "org.rnorth.duct-tape:duct-tape:1.0.7",
sha1 = "a26b5d90d88c91321dc7a3734ea72d2fc019ebb6",
)
maven_jar(
name = "visible-assertions",
artifact = "org.rnorth.visible-assertions:visible-assertions:2.1.2",
sha1 = "20d31a578030ec8e941888537267d3123c2ad1c1",
)
maven_jar(
name = "jna",
artifact = "net.java.dev.jna:jna:5.2.0",
sha1 = "ed8b772eb077a9cb50e44e90899c66a9a6c00e67",
)
maven_jar( maven_jar(
name = "javax-activation", name = "javax-activation",
artifact = "javax.activation:activation:1.1.1", artifact = "javax.activation:activation:1.1.1",

View File

@@ -342,7 +342,7 @@ class InProcessProtocol extends TestProtocol<Context> {
ImmutableList.<PostReceiveHook>builder() ImmutableList.<PostReceiveHook>builder()
.add( .add(
(pack, commands) -> { (pack, commands) -> {
if (affectsSize(pack, commands)) { if (affectsSize(pack)) {
try { try {
quotaBackend quotaBackend
.user(identifiedUser) .user(identifiedUser)

View File

@@ -15,10 +15,12 @@
package com.google.gerrit.extensions.api.changes; package com.google.gerrit.extensions.api.changes;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace; import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.extensions.common.BlameInfo;
import com.google.gerrit.extensions.common.DiffInfo; import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.NotImplementedException; import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.List;
import java.util.OptionalInt; import java.util.OptionalInt;
public interface FileApi { public interface FileApi {
@@ -42,6 +44,12 @@ public interface FileApi {
/** Set the file reviewed or not reviewed */ /** Set the file reviewed or not reviewed */
void setReviewed(boolean reviewed) throws RestApiException; void setReviewed(boolean reviewed) throws RestApiException;
/**
* Creates a request to retrieve the blame information. On the returned request formatting options
* for the blame request can be set.
*/
BlameRequest blameRequest() throws RestApiException;
abstract class DiffRequest { abstract class DiffRequest {
private String base; private String base;
private Integer context; private Integer context;
@@ -97,6 +105,21 @@ public interface FileApi {
} }
} }
abstract class BlameRequest {
private boolean forBase;
public abstract List<BlameInfo> get() throws RestApiException;
public BlameRequest forBase(boolean forBase) {
this.forBase = forBase;
return this;
}
public boolean isForBase() {
return forBase;
}
}
/** /**
* A default implementation which allows source compatibility when adding new methods to the * A default implementation which allows source compatibility when adding new methods to the
* interface. * interface.
@@ -131,5 +154,10 @@ public interface FileApi {
public void setReviewed(boolean reviewed) throws RestApiException { public void setReviewed(boolean reviewed) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public BlameRequest blameRequest() throws RestApiException {
throw new NotImplementedException();
}
} }
} }

View File

@@ -17,16 +17,20 @@ package com.google.gerrit.server.api.changes;
import static com.google.gerrit.server.api.ApiUtil.asRestApiException; import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.extensions.api.changes.FileApi; import com.google.gerrit.extensions.api.changes.FileApi;
import com.google.gerrit.extensions.common.BlameInfo;
import com.google.gerrit.extensions.common.DiffInfo; import com.google.gerrit.extensions.common.DiffInfo;
import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.server.change.FileResource; import com.google.gerrit.server.change.FileResource;
import com.google.gerrit.server.restapi.change.GetBlame;
import com.google.gerrit.server.restapi.change.GetContent; import com.google.gerrit.server.restapi.change.GetContent;
import com.google.gerrit.server.restapi.change.GetDiff; import com.google.gerrit.server.restapi.change.GetDiff;
import com.google.gerrit.server.restapi.change.Reviewed; import com.google.gerrit.server.restapi.change.Reviewed;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import java.util.List;
class FileApiImpl implements FileApi { class FileApiImpl implements FileApi {
interface Factory { interface Factory {
@@ -34,6 +38,7 @@ class FileApiImpl implements FileApi {
} }
private final GetContent getContent; private final GetContent getContent;
private final Provider<GetBlame> getBlame;
private final GetDiff getDiff; private final GetDiff getDiff;
private final Reviewed.PutReviewed putReviewed; private final Reviewed.PutReviewed putReviewed;
private final Reviewed.DeleteReviewed deleteReviewed; private final Reviewed.DeleteReviewed deleteReviewed;
@@ -42,11 +47,13 @@ class FileApiImpl implements FileApi {
@Inject @Inject
FileApiImpl( FileApiImpl(
GetContent getContent, GetContent getContent,
Provider<GetBlame> getBlame,
GetDiff getDiff, GetDiff getDiff,
Reviewed.PutReviewed putReviewed, Reviewed.PutReviewed putReviewed,
Reviewed.DeleteReviewed deleteReviewed, Reviewed.DeleteReviewed deleteReviewed,
@Assisted FileResource file) { @Assisted FileResource file) {
this.getContent = getContent; this.getContent = getContent;
this.getBlame = getBlame;
this.getDiff = getDiff; this.getDiff = getDiff;
this.putReviewed = putReviewed; this.putReviewed = putReviewed;
this.deleteReviewed = deleteReviewed; this.deleteReviewed = deleteReviewed;
@@ -132,4 +139,18 @@ class FileApiImpl implements FileApi {
throw asRestApiException("Cannot retrieve diff", e); throw asRestApiException("Cannot retrieve diff", e);
} }
} }
@Override
public BlameRequest blameRequest() throws RestApiException {
return new BlameRequest() {
@Override
public List<BlameInfo> get() throws RestApiException {
try {
return getBlame.get().setBase(isForBase()).apply(file).value();
} catch (Exception e) {
throw asRestApiException("Cannot retrieve blame", e);
}
}
};
}
} }

View File

@@ -19,7 +19,7 @@ import static java.util.stream.Collectors.toMap;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.BaseReceivePack; import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
/** Static utilities for writing git protocol hooks. */ /** Static utilities for writing git protocol hooks. */
@@ -32,8 +32,7 @@ public class HookUtil {
* @return map of refs that were advertised. * @return map of refs that were advertised.
* @throws ServiceMayNotContinueException if a problem occurred. * @throws ServiceMayNotContinueException if a problem occurred.
*/ */
@SuppressWarnings("deprecation") public static Map<String, Ref> ensureAllRefsAdvertised(ReceivePack rp)
public static Map<String, Ref> ensureAllRefsAdvertised(BaseReceivePack rp)
throws ServiceMayNotContinueException { throws ServiceMayNotContinueException {
Map<String, Ref> refs = rp.getAdvertisedRefs(); Map<String, Ref> refs = rp.getAdvertisedRefs();
if (refs != null) { if (refs != null) {

View File

@@ -95,7 +95,7 @@ public class WorkQueue {
@Inject @Inject
WorkQueue(IdGenerator idGenerator, @GerritServerConfig Config cfg, MetricMaker metrics) { WorkQueue(IdGenerator idGenerator, @GerritServerConfig Config cfg, MetricMaker metrics) {
this(idGenerator, cfg.getInt("execution", "defaultThreadPoolSize", 1), metrics); this(idGenerator, Math.max(cfg.getInt("execution", "defaultThreadPoolSize", 2), 2), metrics);
} }
/** Constructor to allow binding the WorkQueue more explicitly in a vhost setup. */ /** Constructor to allow binding the WorkQueue more explicitly in a vhost setup. */

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.server.git.HookUtil;
import java.util.Map; import java.util.Map;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.AdvertiseRefsHook; import org.eclipse.jgit.transport.AdvertiseRefsHook;
import org.eclipse.jgit.transport.BaseReceivePack; import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.UploadPack; import org.eclipse.jgit.transport.UploadPack;
@@ -34,7 +34,7 @@ class AllRefsWatcher implements AdvertiseRefsHook {
private Map<String, Ref> allRefs; private Map<String, Ref> allRefs;
@Override @Override
public void advertiseRefs(BaseReceivePack rp) throws ServiceMayNotContinueException { public void advertiseRefs(ReceivePack rp) throws ServiceMayNotContinueException {
allRefs = HookUtil.ensureAllRefsAdvertised(rp); allRefs = HookUtil.ensureAllRefsAdvertised(rp);
} }

View File

@@ -28,7 +28,7 @@ import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.transport.AdvertiseRefsHook; import org.eclipse.jgit.transport.AdvertiseRefsHook;
import org.eclipse.jgit.transport.BaseReceivePack; import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.UploadPack; import org.eclipse.jgit.transport.UploadPack;
@@ -72,9 +72,8 @@ public class HackPushNegotiateHook implements AdvertiseRefsHook {
throw new UnsupportedOperationException("HackPushNegotiateHook cannot be used for UploadPack"); throw new UnsupportedOperationException("HackPushNegotiateHook cannot be used for UploadPack");
} }
@SuppressWarnings("deprecation")
@Override @Override
public void advertiseRefs(BaseReceivePack rp) throws ServiceMayNotContinueException { public void advertiseRefs(ReceivePack rp) throws ServiceMayNotContinueException {
Map<String, Ref> r = rp.getAdvertisedRefs(); Map<String, Ref> r = rp.getAdvertisedRefs();
if (r == null) { if (r == null) {
try { try {
@@ -90,14 +89,13 @@ public class HackPushNegotiateHook implements AdvertiseRefsHook {
rp.setAdvertisedRefs(r, history(r.values(), rp)); rp.setAdvertisedRefs(r, history(r.values(), rp));
} }
private Set<ObjectId> history(Collection<Ref> refs, BaseReceivePack rp) { private Set<ObjectId> history(Collection<Ref> refs, ReceivePack rp) {
Set<ObjectId> alreadySending = rp.getAdvertisedObjects(); Set<ObjectId> alreadySending = rp.getAdvertisedObjects();
if (MAX_HISTORY <= alreadySending.size()) { if (MAX_HISTORY <= alreadySending.size()) {
return alreadySending; return alreadySending;
} }
// Scan history until the advertisement is full. // Scan history until the advertisement is full.
@SuppressWarnings("deprecation")
RevWalk rw = rp.getRevWalk(); RevWalk rw = rp.getRevWalk();
rw.reset(); rw.reset();
try { try {

View File

@@ -61,7 +61,7 @@ public class LazyPostReceiveHookChain implements PostReceiveHook {
@Override @Override
public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) { public void onPostReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
hooks.runEach(h -> h.onPostReceive(rp, commands)); hooks.runEach(h -> h.onPostReceive(rp, commands));
if (affectsSize(rp, commands)) { if (affectsSize(rp)) {
QuotaResponse.Aggregated a = QuotaResponse.Aggregated a =
quotaBackend quotaBackend
.user(user) .user(user)
@@ -78,10 +78,7 @@ public class LazyPostReceiveHookChain implements PostReceiveHook {
} }
} }
public static boolean affectsSize(ReceivePack rp, Collection<ReceiveCommand> commands) { public static boolean affectsSize(ReceivePack rp) {
if (commands.stream().allMatch(c -> c.getType() == ReceiveCommand.Type.DELETE)) { return rp.hasReceivedPack() && rp.getPackSize() > 0L;
return false;
}
return rp.getPackSize() > 0L;
} }
} }

View File

@@ -36,7 +36,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.AdvertiseRefsHook; import org.eclipse.jgit.transport.AdvertiseRefsHook;
import org.eclipse.jgit.transport.BaseReceivePack; import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.UploadPack; import org.eclipse.jgit.transport.UploadPack;
@@ -78,9 +78,8 @@ public class ReceiveCommitsAdvertiseRefsHook implements AdvertiseRefsHook {
"ReceiveCommitsAdvertiseRefsHook cannot be used for UploadPack"); "ReceiveCommitsAdvertiseRefsHook cannot be used for UploadPack");
} }
@SuppressWarnings("deprecation")
@Override @Override
public void advertiseRefs(BaseReceivePack rp) throws ServiceMayNotContinueException { public void advertiseRefs(ReceivePack rp) throws ServiceMayNotContinueException {
Map<String, Ref> advertisedRefs = HookUtil.ensureAllRefsAdvertised(rp); Map<String, Ref> advertisedRefs = HookUtil.ensureAllRefsAdvertised(rp);
advertisedRefs.keySet().stream() advertisedRefs.keySet().stream()
.filter(ReceiveCommitsAdvertiseRefsHook::skip) .filter(ReceiveCommitsAdvertiseRefsHook::skip)

View File

@@ -76,6 +76,11 @@ public class GetBlame implements RestReadView<FileResource> {
this.autoMerger = autoMerger; this.autoMerger = autoMerger;
} }
public GetBlame setBase(boolean base) {
this.base = base;
return this;
}
@Override @Override
public Response<List<BlameInfo>> apply(FileResource resource) public Response<List<BlameInfo>> apply(FileResource resource)
throws RestApiException, IOException, InvalidChangeOperationException { throws RestApiException, IOException, InvalidChangeOperationException {

View File

@@ -51,6 +51,11 @@ public class DelegateSystemReader extends SystemReader {
return delegate.openSystemConfig(parent, fs); return delegate.openSystemConfig(parent, fs);
} }
@Override
public FileBasedConfig openJGitConfig(Config parent, FS fs) {
return delegate.openJGitConfig(parent, fs);
}
@Override @Override
public long getCurrentTime() { public long getCurrentTime() {
return delegate.getCurrentTime(); return delegate.getCurrentTime();

View File

@@ -0,0 +1,128 @@
// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.api.revision;
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.extensions.common.BlameInfo;
import com.google.gerrit.extensions.common.RangeInfo;
import java.util.List;
import org.junit.Test;
public class GetBlameIT extends AbstractDaemonTest {
@Test
public void forNonExistingFile() throws Exception {
PushOneCommit.Result r = createChange("Test Change", "foo.txt", "FOO");
List<BlameInfo> blameInfos =
gApi.changes().id(r.getChangeId()).current().file("non-existing.txt").blameRequest().get();
// File doesn't exist in commit.
assertThat(blameInfos).isEmpty();
}
@Test
public void forNonExistingFileFromBase() throws Exception {
PushOneCommit.Result r = createChange("Test Change", "foo.txt", "FOO");
List<BlameInfo> blameInfos =
gApi.changes()
.id(r.getChangeId())
.current()
.file("non-existing.txt")
.blameRequest()
.forBase(true)
.get();
// File doesn't exist in base commit.
assertThat(blameInfos).isEmpty();
}
@Test
public void forNewlyAddedFile() throws Exception {
PushOneCommit.Result r = createChange("Test Change", "foo.txt", "FOO");
List<BlameInfo> blameInfos =
gApi.changes().id(r.getChangeId()).current().file("foo.txt").blameRequest().get();
assertThat(blameInfos).hasSize(1);
BlameInfo blameInfo = blameInfos.get(0);
assertThat(blameInfo.author).isEqualTo(admin.fullName());
assertThat(blameInfo.id).isEqualTo(r.getCommit().getId().name());
assertThat(blameInfo.commitMsg).isEqualTo(r.getCommit().getFullMessage());
assertThat(blameInfo.time).isEqualTo(r.getCommit().getCommitTime());
assertThat(blameInfo.ranges).hasSize(1);
RangeInfo rangeInfo = blameInfo.ranges.get(0);
assertThat(rangeInfo.start).isEqualTo(1);
assertThat(rangeInfo.end).isEqualTo(1);
}
@Test
public void forNewlyAddedFileFromBase() throws Exception {
String changeId = createChange("Test Change", "foo.txt", "FOO").getChangeId();
List<BlameInfo> blameInfos =
gApi.changes().id(changeId).current().file("foo.txt").blameRequest().forBase(true).get();
// File doesn't exist in base commit.
assertThat(blameInfos).isEmpty();
}
@Test
public void forRecreatedFile() throws Exception {
// Create change that adds 'foo.txt'.
createChange("Change 1", "foo.txt", "FOO");
// Create change that deletes 'foo.txt'.
pushFactory
.create(admin.newIdent(), testRepo, "Change 2", "foo.txt", "FOO")
.rm("refs/for/master");
// Create change that recreates 'foo.txt'.
PushOneCommit.Result r = createChange("Change 3", "foo.txt", "FOO");
List<BlameInfo> blameInfos =
gApi.changes().id(r.getChangeId()).current().file("foo.txt").blameRequest().get();
assertThat(blameInfos).hasSize(1);
BlameInfo blameInfo = blameInfos.get(0);
assertThat(blameInfo.author).isEqualTo(admin.fullName());
assertThat(blameInfo.id).isEqualTo(r.getCommit().getId().name());
assertThat(blameInfo.commitMsg).isEqualTo(r.getCommit().getFullMessage());
assertThat(blameInfo.time).isEqualTo(r.getCommit().getCommitTime());
assertThat(blameInfo.ranges).hasSize(1);
RangeInfo rangeInfo = blameInfo.ranges.get(0);
assertThat(rangeInfo.start).isEqualTo(1);
assertThat(rangeInfo.end).isEqualTo(1);
}
@Test
public void forRecreatedFileFromBase() throws Exception {
// Create change that adds 'foo.txt'.
createChange("Change 1", "foo.txt", "FOO");
// Create change that deletes 'foo.txt'.
pushFactory
.create(admin.newIdent(), testRepo, "Change 2", "foo.txt", "FOO")
.rm("refs/for/master");
// Create change that recreates 'foo.txt'.
String changeId3 = createChange("Change 3", "foo.txt", "FOO").getChangeId();
List<BlameInfo> blameInfos =
gApi.changes().id(changeId3).current().file("foo.txt").blameRequest().forBase(true).get();
// File doesn't exist in base commit.
assertThat(blameInfos).isEmpty();
}
}

File diff suppressed because one or more lines are too long

View File

@@ -11,7 +11,36 @@ TMP=$(mktemp -d || mktemp -d -t /tmp/tmp.XXXXXX)
grep 'name = "[^"]*"' ${bzl} | sed 's|^[^"]*"||g;s|".*$||g' | sort > $TMP/names grep 'name = "[^"]*"' ${bzl} | sed 's|^[^"]*"||g;s|".*$||g' | sort > $TMP/names
cat << EOF > $TMP/want cat << EOF > $TMP/want
cglib-3_2
dropwizard-core
duct-tape
eddsa
elasticsearch-rest-client
httpasyncclient
httpcore-nio
j2objc
jackson-core
javassist
jna
jruby
mina-core
nekohtml
objenesis
openid-consumer
powermock-api-easymock
powermock-api-support
powermock-core
powermock-module-junit4
powermock-module-junit4-common
powermock-reflect
sshd
sshd-common
sshd-mina
testcontainers
testcontainers-elasticsearch
tukaani-xz tukaani-xz
visible-assertions
xerces
EOF EOF
diff -u $TMP/names $TMP/want diff -u $TMP/names $TMP/want

View File

@@ -75,6 +75,7 @@ limitations under the License.
border-right: 0; border-right: 0;
border-left: 0; border-left: 0;
border-top: 0; border-top: 0;
box-shadow: var(--header-box-shadow);
} }
footer { footer {
background: var(--footer-background, var(--footer-background-color, #eee)); background: var(--footer-background, var(--footer-background-color, #eee));

View File

@@ -109,6 +109,7 @@ html {
--header-background-color: #eee; --header-background-color: #eee;
--header-border-bottom: 1px solid var(--border-color); --header-border-bottom: 1px solid var(--border-color);
--header-border-image: ''; --header-border-image: '';
--header-box-shadow: none;
--header-padding: 0 var(--spacing-l); --header-padding: 0 var(--spacing-l);
--header-icon-size: 0em; --header-icon-size: 0em;
--header-icon: none; --header-icon: none;

View File

@@ -8,9 +8,196 @@ def declare_nongoogle_deps():
enforced by //lib:nongoogle_test. enforced by //lib:nongoogle_test.
""" """
maven_jar(
name = "j2objc",
artifact = "com.google.j2objc:j2objc-annotations:1.1",
sha1 = "ed28ded51a8b1c6b112568def5f4b455e6809019",
)
# Transitive dependency of commons-compress # Transitive dependency of commons-compress
maven_jar( maven_jar(
name = "tukaani-xz", name = "tukaani-xz",
artifact = "org.tukaani:xz:1.8", artifact = "org.tukaani:xz:1.8",
sha1 = "c4f7d054303948eb6a4066194253886c8af07128", sha1 = "c4f7d054303948eb6a4066194253886c8af07128",
) )
maven_jar(
name = "dropwizard-core",
artifact = "io.dropwizard.metrics:metrics-core:4.1.1",
sha1 = "ebfafc716d9c3b6151dc7c2c09ce925a163a4f21",
)
SSHD_VERS = "2.3.0"
maven_jar(
name = "sshd",
artifact = "org.apache.sshd:sshd-core:" + SSHD_VERS,
sha1 = "21aeea9deba96c9b81ea0935fa4fac61aa3cf646",
)
maven_jar(
name = "sshd-common",
artifact = "org.apache.sshd:sshd-common:" + SSHD_VERS,
sha1 = "8b6e3baaa0d35b547696965eef3e62477f5e74c9",
)
maven_jar(
name = "eddsa",
artifact = "net.i2p.crypto:eddsa:0.3.0",
sha1 = "1901c8d4d8bffb7d79027686cfb91e704217c3e1",
)
maven_jar(
name = "mina-core",
artifact = "org.apache.mina:mina-core:2.0.21",
sha1 = "e1a317689ecd438f54e863747e832f741ef8e092",
)
maven_jar(
name = "sshd-mina",
artifact = "org.apache.sshd:sshd-mina:" + SSHD_VERS,
sha1 = "55dc0830dfcbceba01f9460812ee454978a15fe8",
)
# elasticsearch-rest-client explicitly depends on this version
maven_jar(
name = "httpasyncclient",
artifact = "org.apache.httpcomponents:httpasyncclient:4.1.4",
sha1 = "f3a3240681faae3fa46b573a4c7e50cec9db0d86",
)
# elasticsearch-rest-client explicitly depends on this version
maven_jar(
name = "httpcore-nio",
artifact = "org.apache.httpcomponents:httpcore-nio:4.4.11",
sha1 = "7d0a97d01d39cff9aa3e6db81f21fddb2435f4e6",
)
maven_jar(
name = "openid-consumer",
artifact = "org.openid4java:openid4java:1.0.0",
sha1 = "541091bb49f2c0d583544c5bb1e6df7612d31e3e",
)
maven_jar(
name = "nekohtml",
artifact = "net.sourceforge.nekohtml:nekohtml:1.9.10",
sha1 = "14052461031a7054aa094f5573792feb6686d3de",
)
maven_jar(
name = "xerces",
artifact = "xerces:xercesImpl:2.8.1",
attach_source = False,
sha1 = "25101e37ec0c907db6f0612cbf106ee519c1aef1",
)
maven_jar(
name = "jruby",
artifact = "org.jruby:jruby-complete:9.1.17.0",
sha1 = "76716d529710fc03d1d429b43e3cedd4419f78d4",
)
# When upgrading elasticsearch-rest-client, also upgrade httpcore-nio
# and httpasyncclient as necessary.
maven_jar(
name = "elasticsearch-rest-client",
artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.4.2",
sha1 = "f48725523c0b3402f869214433602f8d3f4c737c",
)
maven_jar(
name = "jackson-core",
artifact = "com.fasterxml.jackson.core:jackson-core:2.10.1",
sha1 = "2c8b5e26ba40e5f91eb37a24075a2028b402c5f9",
)
# Test-only dependencies below.
maven_jar(
name = "cglib-3_2",
artifact = "cglib:cglib-nodep:3.2.6",
sha1 = "92bf48723d277d6efd1150b2f7e9e1e92cb56caf",
)
maven_jar(
name = "objenesis",
artifact = "org.objenesis:objenesis:1.3",
sha1 = "dc13ae4faca6df981fc7aeb5a522d9db446d5d50",
)
POWERM_VERS = "1.6.1"
maven_jar(
name = "powermock-module-junit4",
artifact = "org.powermock:powermock-module-junit4:" + POWERM_VERS,
sha1 = "ea8530b2848542624f110a393513af397b37b9cf",
)
maven_jar(
name = "powermock-module-junit4-common",
artifact = "org.powermock:powermock-module-junit4-common:" + POWERM_VERS,
sha1 = "7222ced54dabc310895d02e45c5428ca05193cda",
)
maven_jar(
name = "powermock-reflect",
artifact = "org.powermock:powermock-reflect:" + POWERM_VERS,
sha1 = "97d25eda8275c11161bcddda6ef8beabd534c878",
)
maven_jar(
name = "powermock-api-easymock",
artifact = "org.powermock:powermock-api-easymock:" + POWERM_VERS,
sha1 = "aa740ecf89a2f64d410b3d93ef8cd6833009ef00",
)
maven_jar(
name = "powermock-api-support",
artifact = "org.powermock:powermock-api-support:" + POWERM_VERS,
sha1 = "592ee6d929c324109d3469501222e0c76ccf0869",
)
maven_jar(
name = "powermock-core",
artifact = "org.powermock:powermock-core:" + POWERM_VERS,
sha1 = "5afc1efce8d44ed76b30af939657bd598e45d962",
)
maven_jar(
name = "javassist",
artifact = "org.javassist:javassist:3.22.0-GA",
sha1 = "3e83394258ae2089be7219b971ec21a8288528ad",
)
TESTCONTAINERS_VERSION = "1.12.3"
maven_jar(
name = "testcontainers",
artifact = "org.testcontainers:testcontainers:" + TESTCONTAINERS_VERSION,
sha1 = "e424a4549640e120acceac641ac909fcda58bf62",
)
maven_jar(
name = "testcontainers-elasticsearch",
artifact = "org.testcontainers:elasticsearch:" + TESTCONTAINERS_VERSION,
sha1 = "c0796de5032070b8768ce78c78949b48f13c30db",
)
maven_jar(
name = "duct-tape",
artifact = "org.rnorth.duct-tape:duct-tape:1.0.7",
sha1 = "a26b5d90d88c91321dc7a3734ea72d2fc019ebb6",
)
maven_jar(
name = "visible-assertions",
artifact = "org.rnorth.visible-assertions:visible-assertions:2.1.2",
sha1 = "20d31a578030ec8e941888537267d3123c2ad1c1",
)
maven_jar(
name = "jna",
artifact = "net.java.dev.jna:jna:5.2.0",
sha1 = "ed8b772eb077a9cb50e44e90899c66a9a6c00e67",
)