Merge changes I374e9081,I9310b58f,I6df14c97,I93d0c7cd
* changes: Update .mailmap InitPluginStepsLoader: Remove redundant warning suppression Upgrade auto-value to 1.6 Merge branch 'stable-2.15'
This commit is contained in:
commit
cd80425b54
2
.mailmap
2
.mailmap
@ -10,6 +10,7 @@ Brad Larson <bklarson@gmail.com>
|
||||
Bruce Zu <bruce.zu.run10@gmail.com> <bruce.zu@sonyericsson.com>
|
||||
Bruce Zu <bruce.zu.run10@gmail.com> <bruce.zu@sonymobile.com>
|
||||
Carlos Eduardo Baldacin <carloseduardo.baldacin@sonyericsson.com> carloseduardo.baldacin <carloseduardo.baldacin@sonyericsson.com>
|
||||
Changcheng Xiao <xchangcheng@google.com> xchangcheng
|
||||
Dariusz Luksza <dluksza@collab.net> <dariusz@luksza.org>
|
||||
Dave Borowitz <dborowitz@google.com> <dborowitz@google.com>
|
||||
David Ostrovsky <david@ostrovsky.org> <d.ostrovsky@gmx.de>
|
||||
@ -67,6 +68,7 @@ Ulrik Sjölin <ulrik.sjolin@sonyericsson.com>
|
||||
Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> Ulrik Sjolin <ulrik.sjolin@gmail.com>
|
||||
Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> Ulrik Sjölin <ulrik.sjolin@sonyericsson.com>
|
||||
Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> Ulrik Sjolin <ulrik.sjolin@sonyericsson.com>
|
||||
Viktar Donich <viktard@google.com> viktard
|
||||
Yuxuan 'fishy' Wang <fishywang@google.com> Yuxuan Wang <fishywang@google.com>
|
||||
Zalán Blénessy <zalanb@axis.com> Zalan Blenessy <zalanb@axis.com>
|
||||
飞 李 <lifei@7v1.net> lifei <lifei@7v1.net>
|
||||
|
@ -31,12 +31,13 @@ This command is intended to be used in scripts.
|
||||
Currently supported values:
|
||||
* changes
|
||||
* accounts
|
||||
* groups
|
||||
|
||||
== EXAMPLES
|
||||
Activate the latest change index:
|
||||
|
||||
----
|
||||
$ ssh -p 29418 review.example.com gerrit activate changes
|
||||
$ ssh -p 29418 review.example.com gerrit index activate changes
|
||||
----
|
||||
|
||||
GERRIT
|
||||
|
@ -108,7 +108,9 @@ Changes originally submitted by 'USER'. The special case of
|
||||
[[ownerin]]
|
||||
ownerin:'GROUP'::
|
||||
+
|
||||
Changes originally submitted by a user in 'GROUP'.
|
||||
Changes originally submitted by a user in 'GROUP'. When no other index
|
||||
predicate is explicitly added in the query, defaults to only include
|
||||
changes in status 'OPEN'.
|
||||
|
||||
[[query]]
|
||||
query:'NAME'::
|
||||
@ -137,7 +139,9 @@ Changes that revert the change specified by the numeric 'ID'.
|
||||
[[reviewerin]]
|
||||
reviewerin:'GROUP'::
|
||||
+
|
||||
Changes that have been, or need to be, reviewed by a user in 'GROUP'.
|
||||
Changes that have been, or need to be, reviewed by a user in 'GROUP'. When
|
||||
no other index predicate is explicitly added in the query, defaults to only
|
||||
include changes in status 'OPEN'.
|
||||
|
||||
[[commit]]
|
||||
commit:'SHA1'::
|
||||
@ -338,6 +342,11 @@ is:reviewer::
|
||||
True on any change where the current user is a reviewer.
|
||||
Same as `reviewer:self`.
|
||||
|
||||
is:cc::
|
||||
+
|
||||
True on any change where the current user is in CC.
|
||||
Same as `cc:self`.
|
||||
|
||||
is:open, is:pending::
|
||||
+
|
||||
True if the change is open.
|
||||
|
49
WORKSPACE
49
WORKSPACE
@ -415,10 +415,18 @@ maven_jar(
|
||||
sha1 = "430b2fc839b5de1f3643b528853d5cf26096c1de",
|
||||
)
|
||||
|
||||
AUTO_VALUE_VERSION = "1.6"
|
||||
|
||||
maven_jar(
|
||||
name = "auto_value",
|
||||
artifact = "com.google.auto.value:auto-value:1.5.4",
|
||||
sha1 = "65183ddd1e9542d69d8f613fdae91540d04e1476",
|
||||
artifact = "com.google.auto.value:auto-value:" + AUTO_VALUE_VERSION,
|
||||
sha1 = "a3b1b1404f8acaa88594a017185e013cd342c9a8",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "auto_value_annotations",
|
||||
artifact = "com.google.auto.value:auto-value-annotations:" + AUTO_VALUE_VERSION,
|
||||
sha1 = "da725083ee79fdcd86d9f3d8a76e38174a01892a",
|
||||
)
|
||||
|
||||
# Transitive dependency of commons-compress
|
||||
@ -443,12 +451,6 @@ maven_jar(
|
||||
sha1 = "08ce9d34c8124c80e176e8332ee947480bbb9576",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "lucene_codecs",
|
||||
artifact = "org.apache.lucene:lucene-codecs:" + LUCENE_VERS,
|
||||
sha1 = "afdad570668469b1734fbd32b8f98561561bed48",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "backward_codecs",
|
||||
artifact = "org.apache.lucene:lucene-backward-codecs:" + LUCENE_VERS,
|
||||
@ -485,12 +487,6 @@ maven_jar(
|
||||
sha1 = "4dbdc2e1a24837722294762a9edb479f79092ab9",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "lucene_sandbox",
|
||||
artifact = "org.apache.lucene:lucene-sandbox:" + LUCENE_VERS,
|
||||
sha1 = "49498bbb2adc333e98bdca4bf6170ae770cbad11",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "lucene_spatial",
|
||||
artifact = "org.apache.lucene:lucene-spatial:" + LUCENE_VERS,
|
||||
@ -967,12 +963,6 @@ maven_jar(
|
||||
sha1 = "84ccf145ac2215e6bfa63baa3101c0af41017cfc",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "jna",
|
||||
artifact = "net.java.dev.jna:jna:4.1.0",
|
||||
sha1 = "1c12d070e602efd8021891cdd7fd18bc129372d4",
|
||||
)
|
||||
|
||||
JACKSON_VERSION = "2.8.9"
|
||||
|
||||
maven_jar(
|
||||
@ -981,18 +971,18 @@ maven_jar(
|
||||
sha1 = "569b1752705da98f49aabe2911cc956ff7d8ed9d",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "jackson_dataformat_smile",
|
||||
artifact = "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:" + JACKSON_VERSION,
|
||||
sha1 = "d36cbae6b06ac12fca16fda403759e479316141b",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "jackson_dataformat_cbor",
|
||||
artifact = "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:" + JACKSON_VERSION,
|
||||
sha1 = "93242092324cad33d777e06c0515e40a6b862659",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "jackson_dataformat_smile",
|
||||
artifact = "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:" + JACKSON_VERSION,
|
||||
sha1 = "d36cbae6b06ac12fca16fda403759e479316141b",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "httpasyncclient",
|
||||
artifact = "org.apache.httpcomponents:httpasyncclient:4.1.2",
|
||||
@ -1005,13 +995,6 @@ maven_jar(
|
||||
sha1 = "a8c5e3c3bfea5ce23fb647c335897e415eb442e3",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "httpcore_niossl",
|
||||
artifact = "org.apache.httpcomponents:httpcore-niossl:4.0-alpha6",
|
||||
attach_source = False,
|
||||
sha1 = "9c662e7247ca8ceb1de5de629f685c9ef3e4ab58",
|
||||
)
|
||||
|
||||
load("//tools/bzl:js.bzl", "npm_binary", "bower_archive")
|
||||
|
||||
npm_binary(
|
||||
|
@ -78,6 +78,7 @@ java_library2(
|
||||
"//lib:truth",
|
||||
"//lib:truth-java8-extension",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/httpcomponents:fluent-hc",
|
||||
"//lib/httpcomponents:httpclient",
|
||||
"//lib/httpcomponents:httpcore",
|
||||
|
@ -23,6 +23,7 @@ gwt_module(
|
||||
"//lib:gwtorm_client",
|
||||
"//lib:servlet-api-3_1",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
"//lib/log:api",
|
||||
],
|
||||
@ -48,6 +49,7 @@ java_library(
|
||||
"//lib:gwtorm",
|
||||
"//lib:servlet-api-3_1",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
"//lib/log:api",
|
||||
],
|
||||
|
@ -189,21 +189,24 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
|
||||
}
|
||||
|
||||
private String toDocument(V v) throws IOException {
|
||||
XContentBuilder builder = jsonBuilder().startObject();
|
||||
for (Values<V> values : schema.buildFields(v)) {
|
||||
String name = values.getField().getName();
|
||||
if (values.getField().isRepeatable()) {
|
||||
builder.field(
|
||||
name,
|
||||
Streams.stream(values.getValues()).filter(e -> shouldAddElement(e)).collect(toList()));
|
||||
} else {
|
||||
Object element = Iterables.getOnlyElement(values.getValues(), "");
|
||||
if (shouldAddElement(element)) {
|
||||
builder.field(name, element);
|
||||
try (XContentBuilder builder = jsonBuilder().startObject()) {
|
||||
for (Values<V> values : schema.buildFields(v)) {
|
||||
String name = values.getField().getName();
|
||||
if (values.getField().isRepeatable()) {
|
||||
builder.field(
|
||||
name,
|
||||
Streams.stream(values.getValues())
|
||||
.filter(e -> shouldAddElement(e))
|
||||
.collect(toList()));
|
||||
} else {
|
||||
Object element = Iterables.getOnlyElement(values.getValues(), "");
|
||||
if (shouldAddElement(element)) {
|
||||
builder.field(name, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.endObject().string();
|
||||
}
|
||||
return builder.endObject().string();
|
||||
}
|
||||
|
||||
protected abstract V fromDocument(JsonObject doc, Set<String> fields);
|
||||
|
@ -30,6 +30,7 @@ java_library(
|
||||
"//lib:servlet-api-3_1",
|
||||
"//lib:soy",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/commons:codec",
|
||||
"//lib/guice",
|
||||
"//lib/guice:guice-assistedinject",
|
||||
|
@ -42,6 +42,7 @@ java_library(
|
||||
"//lib:gwtorm",
|
||||
"//lib/antlr:java_runtime",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
"//lib/log:api",
|
||||
],
|
||||
|
@ -49,6 +49,7 @@ java_library(
|
||||
"//lib:protobuf",
|
||||
"//lib:servlet-api-3_1-without-neverlink",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/guice",
|
||||
"//lib/guice:guice-assistedinject",
|
||||
"//lib/guice:guice-servlet",
|
||||
|
@ -62,7 +62,6 @@ public class InitPluginStepsLoader {
|
||||
return pluginsInitSteps;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
private InitStep loadInitStep(Path jar) {
|
||||
try {
|
||||
URLClassLoader pluginLoader =
|
||||
|
@ -62,6 +62,7 @@ java_library(
|
||||
"//lib:soy",
|
||||
"//lib:tukaani-xz",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/bouncycastle:bcpkix-neverlink",
|
||||
"//lib/bouncycastle:bcprov-neverlink",
|
||||
"//lib/commons:codec",
|
||||
|
@ -52,6 +52,9 @@ public class VersionedAccountDestinations extends VersionedMetaData {
|
||||
|
||||
@Override
|
||||
protected void onLoad() throws IOException, ConfigInvalidException {
|
||||
if (revision == null) {
|
||||
return;
|
||||
}
|
||||
String prefix = DestinationList.DIR_NAME + "/";
|
||||
for (PathInfo p : getPathInfos(true)) {
|
||||
if (p.fileMode == FileMode.REGULAR_FILE) {
|
||||
|
@ -34,7 +34,7 @@ import com.google.inject.Singleton;
|
||||
import eu.medsea.mimeutil.MimeType;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import org.eclipse.jgit.errors.LargeObjectException;
|
||||
@ -42,7 +42,6 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectLoader;
|
||||
import org.eclipse.jgit.lib.ObjectReader;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
@ -57,7 +56,7 @@ public class FileContentUtil {
|
||||
private static final String X_GIT_GITLINK = "x-git/gitlink";
|
||||
private static final int MAX_SIZE = 5 << 20;
|
||||
private static final String ZIP_TYPE = "application/zip";
|
||||
private static final Random rng = new Random();
|
||||
private static final SecureRandom rng = new SecureRandom();
|
||||
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final FileTypeRegistry registry;
|
||||
@ -104,35 +103,35 @@ public class FileContentUtil {
|
||||
throws IOException, ResourceNotFoundException {
|
||||
try (RevWalk rw = new RevWalk(repo)) {
|
||||
RevCommit commit = rw.parseCommit(revstr);
|
||||
ObjectReader reader = rw.getObjectReader();
|
||||
TreeWalk tw = TreeWalk.forPath(reader, path, commit.getTree());
|
||||
if (tw == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
try (TreeWalk tw = TreeWalk.forPath(rw.getObjectReader(), path, commit.getTree())) {
|
||||
if (tw == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
org.eclipse.jgit.lib.FileMode mode = tw.getFileMode(0);
|
||||
ObjectId id = tw.getObjectId(0);
|
||||
if (mode == org.eclipse.jgit.lib.FileMode.GITLINK) {
|
||||
return BinaryResult.create(id.name()).setContentType(X_GIT_GITLINK).base64();
|
||||
}
|
||||
org.eclipse.jgit.lib.FileMode mode = tw.getFileMode(0);
|
||||
ObjectId id = tw.getObjectId(0);
|
||||
if (mode == org.eclipse.jgit.lib.FileMode.GITLINK) {
|
||||
return BinaryResult.create(id.name()).setContentType(X_GIT_GITLINK).base64();
|
||||
}
|
||||
|
||||
ObjectLoader obj = repo.open(id, OBJ_BLOB);
|
||||
byte[] raw;
|
||||
try {
|
||||
raw = obj.getCachedBytes(MAX_SIZE);
|
||||
} catch (LargeObjectException e) {
|
||||
raw = null;
|
||||
}
|
||||
ObjectLoader obj = repo.open(id, OBJ_BLOB);
|
||||
byte[] raw;
|
||||
try {
|
||||
raw = obj.getCachedBytes(MAX_SIZE);
|
||||
} catch (LargeObjectException e) {
|
||||
raw = null;
|
||||
}
|
||||
|
||||
String type;
|
||||
if (mode == org.eclipse.jgit.lib.FileMode.SYMLINK) {
|
||||
type = X_GIT_SYMLINK;
|
||||
} else {
|
||||
type = registry.getMimeType(path, raw).toString();
|
||||
type = resolveContentType(project, path, FileMode.FILE, type);
|
||||
}
|
||||
String type;
|
||||
if (mode == org.eclipse.jgit.lib.FileMode.SYMLINK) {
|
||||
type = X_GIT_SYMLINK;
|
||||
} else {
|
||||
type = registry.getMimeType(path, raw).toString();
|
||||
type = resolveContentType(project, path, FileMode.FILE, type);
|
||||
}
|
||||
|
||||
return asBinaryResult(raw, obj).setContentType(type).base64();
|
||||
return asBinaryResult(raw, obj).setContentType(type).base64();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,30 +165,30 @@ public class FileContentUtil {
|
||||
}
|
||||
commit = rw.parseCommit(commit.getParent(parent - 1));
|
||||
}
|
||||
ObjectReader reader = rw.getObjectReader();
|
||||
TreeWalk tw = TreeWalk.forPath(reader, path, commit.getTree());
|
||||
if (tw == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
try (TreeWalk tw = TreeWalk.forPath(rw.getObjectReader(), path, commit.getTree())) {
|
||||
if (tw == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
int mode = tw.getFileMode(0).getObjectType();
|
||||
if (mode != Constants.OBJ_BLOB) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
int mode = tw.getFileMode(0).getObjectType();
|
||||
if (mode != Constants.OBJ_BLOB) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
ObjectId id = tw.getObjectId(0);
|
||||
ObjectLoader obj = repo.open(id, OBJ_BLOB);
|
||||
byte[] raw;
|
||||
try {
|
||||
raw = obj.getCachedBytes(MAX_SIZE);
|
||||
} catch (LargeObjectException e) {
|
||||
raw = null;
|
||||
}
|
||||
ObjectId id = tw.getObjectId(0);
|
||||
ObjectLoader obj = repo.open(id, OBJ_BLOB);
|
||||
byte[] raw;
|
||||
try {
|
||||
raw = obj.getCachedBytes(MAX_SIZE);
|
||||
} catch (LargeObjectException e) {
|
||||
raw = null;
|
||||
}
|
||||
|
||||
MimeType contentType = registry.getMimeType(path, raw);
|
||||
return registry.isSafeInline(contentType)
|
||||
? wrapBlob(path, obj, raw, contentType, suffix)
|
||||
: zipBlob(path, obj, commit, suffix);
|
||||
MimeType contentType = registry.getMimeType(path, raw);
|
||||
return registry.isSafeInline(contentType)
|
||||
? wrapBlob(path, obj, raw, contentType, suffix)
|
||||
: zipBlob(path, obj, commit, suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,10 +481,11 @@ public abstract class VersionedMetaData {
|
||||
return new byte[] {};
|
||||
}
|
||||
|
||||
TreeWalk tw = TreeWalk.forPath(reader, fileName, revision.getTree());
|
||||
if (tw != null) {
|
||||
ObjectLoader obj = reader.open(tw.getObjectId(0), Constants.OBJ_BLOB);
|
||||
return obj.getCachedBytes(Integer.MAX_VALUE);
|
||||
try (TreeWalk tw = TreeWalk.forPath(reader, fileName, revision.getTree())) {
|
||||
if (tw != null) {
|
||||
ObjectLoader obj = reader.open(tw.getObjectId(0), Constants.OBJ_BLOB);
|
||||
return obj.getCachedBytes(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
return new byte[] {};
|
||||
}
|
||||
@ -495,9 +496,10 @@ public abstract class VersionedMetaData {
|
||||
return null;
|
||||
}
|
||||
|
||||
TreeWalk tw = TreeWalk.forPath(reader, fileName, revision.getTree());
|
||||
if (tw != null) {
|
||||
return tw.getObjectId(0);
|
||||
try (TreeWalk tw = TreeWalk.forPath(reader, fileName, revision.getTree())) {
|
||||
if (tw != null) {
|
||||
return tw.getObjectId(0);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -13,6 +13,7 @@ java_library(
|
||||
"//lib:guava",
|
||||
"//lib:gwtorm",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/guice",
|
||||
"//lib/guice:guice-assistedinject",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
|
@ -200,30 +200,31 @@ public class SmtpEmailSender implements EmailSender {
|
||||
}
|
||||
}
|
||||
|
||||
Writer messageDataWriter = client.sendMessageData();
|
||||
if (messageDataWriter == null) {
|
||||
/* Include rejected recipient error messages here to not lose that
|
||||
* information. That piece of the puzzle is vital if zero recipients
|
||||
* are accepted and the server consequently rejects the DATA command.
|
||||
*/
|
||||
throw new EmailException(
|
||||
rejected
|
||||
+ "Server "
|
||||
+ smtpHost
|
||||
+ " rejected DATA command: "
|
||||
+ client.getReplyString());
|
||||
}
|
||||
try (Writer messageDataWriter = client.sendMessageData()) {
|
||||
if (messageDataWriter == null) {
|
||||
/* Include rejected recipient error messages here to not lose that
|
||||
* information. That piece of the puzzle is vital if zero recipients
|
||||
* are accepted and the server consequently rejects the DATA command.
|
||||
*/
|
||||
throw new EmailException(
|
||||
rejected
|
||||
+ "Server "
|
||||
+ smtpHost
|
||||
+ " rejected DATA command: "
|
||||
+ client.getReplyString());
|
||||
}
|
||||
|
||||
render(messageDataWriter, callerHeaders, textBody, htmlBody);
|
||||
render(messageDataWriter, callerHeaders, textBody, htmlBody);
|
||||
|
||||
if (!client.completePendingCommand()) {
|
||||
throw new EmailException(
|
||||
"Server " + smtpHost + " rejected message body: " + client.getReplyString());
|
||||
}
|
||||
if (!client.completePendingCommand()) {
|
||||
throw new EmailException(
|
||||
"Server " + smtpHost + " rejected message body: " + client.getReplyString());
|
||||
}
|
||||
|
||||
client.logout();
|
||||
if (rejected.length() > 0) {
|
||||
throw new EmailException(rejected.toString());
|
||||
client.logout();
|
||||
if (rejected.length() > 0) {
|
||||
throw new EmailException(rejected.toString());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
client.disconnect();
|
||||
|
@ -615,6 +615,7 @@ public class NoteDbMigrator implements AutoCloseable {
|
||||
log.warn(
|
||||
"Change {} previously failed to rebuild;"
|
||||
+ " skipping primary storage migration",
|
||||
id,
|
||||
e);
|
||||
} else {
|
||||
throw e;
|
||||
@ -724,6 +725,7 @@ public class NoteDbMigrator implements AutoCloseable {
|
||||
|
||||
// Only set in-memory state once it's been persisted to storage.
|
||||
globalNotesMigration.setFrom(newState);
|
||||
log.info("Migration state: {} => {}", expectedOldState, newState);
|
||||
|
||||
return newState;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData>
|
||||
logger.info("No such project: {}", cd.project());
|
||||
return false;
|
||||
}
|
||||
throw new OrmException("unable to check permissions", e);
|
||||
throw new OrmException("unable to check permissions on change " + cd.getId(), e);
|
||||
}
|
||||
if (visible) {
|
||||
cd.cacheVisibleTo(user);
|
||||
|
@ -1103,7 +1103,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
||||
VersionedAccountDestinations d = VersionedAccountDestinations.forUser(self());
|
||||
d.load(git);
|
||||
Set<Branch.NameKey> destinations = d.getDestinationList().getDestinations(name);
|
||||
if (destinations != null) {
|
||||
if (destinations != null && !destinations.isEmpty()) {
|
||||
return new DestinationPredicate(destinations, name);
|
||||
}
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
|
@ -25,6 +25,7 @@ java_library(
|
||||
"//lib:gwtorm",
|
||||
"//lib:servlet-api-3_1",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/commons:codec",
|
||||
"//lib/commons:compress",
|
||||
"//lib/commons:lang",
|
||||
|
@ -16,6 +16,7 @@ java_library(
|
||||
"//lib:guava",
|
||||
"//lib:gwtorm",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/commons:dbcp",
|
||||
"//lib/guice",
|
||||
"//lib/jgit/org.eclipse.jgit.archive:jgit-archive",
|
||||
|
@ -25,6 +25,7 @@ java_library(
|
||||
"//lib:jsch",
|
||||
"//lib:servlet-api-3_1",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/bouncycastle:bcprov-neverlink",
|
||||
"//lib/commons:codec",
|
||||
"//lib/dropwizard:dropwizard-core",
|
||||
|
@ -32,6 +32,7 @@ java_library(
|
||||
"//lib:h2",
|
||||
"//lib:truth",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/guice",
|
||||
"//lib/guice:guice-servlet",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
|
@ -846,16 +846,18 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
||||
|
||||
private <T> T readContentFromJson(RestResponse r, Class<T> clazz) throws Exception {
|
||||
r.assertOK();
|
||||
JsonReader jsonReader = new JsonReader(r.getReader());
|
||||
jsonReader.setLenient(true);
|
||||
return newGson().fromJson(jsonReader, clazz);
|
||||
try (JsonReader jsonReader = new JsonReader(r.getReader())) {
|
||||
jsonReader.setLenient(true);
|
||||
return newGson().fromJson(jsonReader, clazz);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T readContentFromJson(RestResponse r, TypeToken<T> typeToken) throws Exception {
|
||||
r.assertOK();
|
||||
JsonReader jsonReader = new JsonReader(r.getReader());
|
||||
jsonReader.setLenient(true);
|
||||
return newGson().fromJson(jsonReader, typeToken.getType());
|
||||
try (JsonReader jsonReader = new JsonReader(r.getReader())) {
|
||||
jsonReader.setLenient(true);
|
||||
return newGson().fromJson(jsonReader, typeToken.getType());
|
||||
}
|
||||
}
|
||||
|
||||
private String readContentFromJson(RestResponse r) throws Exception {
|
||||
|
@ -830,9 +830,10 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
private static <T> T readContentFromJson(RestResponse r, int expectedStatus, Class<T> clazz)
|
||||
throws Exception {
|
||||
r.assertStatus(expectedStatus);
|
||||
JsonReader jsonReader = new JsonReader(r.getReader());
|
||||
jsonReader.setLenient(true);
|
||||
return newGson().fromJson(jsonReader, clazz);
|
||||
try (JsonReader jsonReader = new JsonReader(r.getReader())) {
|
||||
jsonReader.setLenient(true);
|
||||
return newGson().fromJson(jsonReader, clazz);
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertReviewers(
|
||||
|
@ -30,5 +30,6 @@ junit_tests(
|
||||
"//lib:guava",
|
||||
"//lib:truth",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
],
|
||||
)
|
||||
|
@ -55,6 +55,7 @@ junit_tests(
|
||||
"//lib:gwtorm",
|
||||
"//lib:truth-java8-extension",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
"//lib/commons:codec",
|
||||
"//lib/guice",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
|
@ -57,6 +57,7 @@ import com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput;
|
||||
import com.google.gerrit.extensions.api.changes.StarsInput;
|
||||
import com.google.gerrit.extensions.api.groups.GroupInput;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.client.ProjectWatchInfo;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
@ -375,6 +376,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
assertQuery("status:pe", expected);
|
||||
assertQuery("status:pen", expected);
|
||||
assertQuery("is:open", expected);
|
||||
assertQuery("is:pending", expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -630,13 +632,15 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
public void byCommit() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
ChangeInserter ins = newChange(repo);
|
||||
insert(repo, ins);
|
||||
Change change = insert(repo, ins);
|
||||
String sha = ins.getCommitId().name();
|
||||
|
||||
assertQuery("0000000000000000000000000000000000000000");
|
||||
assertQuery("commit:0000000000000000000000000000000000000000");
|
||||
for (int i = 0; i <= 36; i++) {
|
||||
String q = sha.substring(0, 40 - i);
|
||||
assertQuery(q, ins.getChange());
|
||||
assertQuery(q, change);
|
||||
assertQuery("commit:" + q, change);
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,6 +652,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
accountManager.authenticate(AuthRequest.forUser("anotheruser")).getAccountId();
|
||||
Change change2 = insert(repo, newChange(repo), user2);
|
||||
|
||||
assertQuery("is:owner", change1);
|
||||
assertQuery("owner:" + userId.get(), change1);
|
||||
assertQuery("owner:" + user2, change2);
|
||||
|
||||
@ -749,6 +754,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
|
||||
assertQuery("ownerin:Administrators", change1);
|
||||
assertQuery("ownerin:\"Registered Users\"", change2, change1);
|
||||
assertQuery("ownerin:\"Registered Users\" project:repo", change3, change2, change1);
|
||||
assertQuery("ownerin:\"Registered Users\" status:merged", change3);
|
||||
}
|
||||
|
||||
@ -765,6 +771,17 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
assertQuery("project:repo2", change2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byParentProject() throws Exception {
|
||||
TestRepository<Repo> repo1 = createProject("repo1");
|
||||
TestRepository<Repo> repo2 = createProject("repo2", "repo1");
|
||||
Change change1 = insert(repo1, newChange(repo1));
|
||||
Change change2 = insert(repo2, newChange(repo2));
|
||||
|
||||
assertQuery("parentproject:repo1", change2, change1);
|
||||
assertQuery("parentproject:repo2", change2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byProjectPrefix() throws Exception {
|
||||
TestRepository<Repo> repo1 = createProject("repo1");
|
||||
@ -1363,7 +1380,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byBefore() throws Exception {
|
||||
public void byBeforeUntil() throws Exception {
|
||||
long thirtyHoursInMs = MILLISECONDS.convert(30, HOURS);
|
||||
resetTimeWithClockStep(thirtyHoursInMs, MILLISECONDS);
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
@ -1372,20 +1389,22 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
Change change2 = insert(repo, newChange(repo), null, new Timestamp(startMs + thirtyHoursInMs));
|
||||
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
||||
|
||||
assertQuery("before:2009-09-29");
|
||||
assertQuery("before:2009-09-30");
|
||||
assertQuery("before:\"2009-09-30 16:59:00 -0400\"");
|
||||
assertQuery("before:\"2009-09-30 20:59:00 -0000\"");
|
||||
assertQuery("before:\"2009-09-30 20:59:00\"");
|
||||
assertQuery("before:\"2009-09-30 17:02:00 -0400\"", change1);
|
||||
assertQuery("before:\"2009-10-01 21:02:00 -0000\"", change1);
|
||||
assertQuery("before:\"2009-10-01 21:02:00\"", change1);
|
||||
assertQuery("before:2009-10-01", change1);
|
||||
assertQuery("before:2009-10-03", change2, change1);
|
||||
for (String predicate : Lists.newArrayList("before:", "until:")) {
|
||||
assertQuery(predicate + "2009-09-29");
|
||||
assertQuery(predicate + "2009-09-30");
|
||||
assertQuery(predicate + "\"2009-09-30 16:59:00 -0400\"");
|
||||
assertQuery(predicate + "\"2009-09-30 20:59:00 -0000\"");
|
||||
assertQuery(predicate + "\"2009-09-30 20:59:00\"");
|
||||
assertQuery(predicate + "\"2009-09-30 17:02:00 -0400\"", change1);
|
||||
assertQuery(predicate + "\"2009-10-01 21:02:00 -0000\"", change1);
|
||||
assertQuery(predicate + "\"2009-10-01 21:02:00\"", change1);
|
||||
assertQuery(predicate + "2009-10-01", change1);
|
||||
assertQuery(predicate + "2009-10-03", change2, change1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byAfter() throws Exception {
|
||||
public void byAfterSince() throws Exception {
|
||||
long thirtyHoursInMs = MILLISECONDS.convert(30, HOURS);
|
||||
resetTimeWithClockStep(thirtyHoursInMs, MILLISECONDS);
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
@ -1394,11 +1413,13 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
Change change2 = insert(repo, newChange(repo), null, new Timestamp(startMs + thirtyHoursInMs));
|
||||
TestTimeUtil.setClockStep(0, MILLISECONDS);
|
||||
|
||||
assertQuery("after:2009-10-03");
|
||||
assertQuery("after:\"2009-10-01 20:59:59 -0400\"", change2);
|
||||
assertQuery("after:\"2009-10-01 20:59:59 -0000\"", change2);
|
||||
assertQuery("after:2009-10-01", change2);
|
||||
assertQuery("after:2009-09-30", change2, change1);
|
||||
for (String predicate : Lists.newArrayList("after:", "since:")) {
|
||||
assertQuery(predicate + "2009-10-03");
|
||||
assertQuery(predicate + "\"2009-10-01 20:59:59 -0400\"", change2);
|
||||
assertQuery(predicate + "\"2009-10-01 20:59:59 -0000\"", change2);
|
||||
assertQuery(predicate + "2009-10-01", change2);
|
||||
assertQuery(predicate + "2009-09-30", change2, change1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1448,13 +1469,13 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
|
||||
assertQuery("deleted:<=0", change1);
|
||||
|
||||
for (String str : Lists.newArrayList("delta", "size")) {
|
||||
assertQuery(str + ":<2");
|
||||
assertQuery(str + ":3", change1);
|
||||
assertQuery(str + ":>2", change1);
|
||||
assertQuery(str + ":>=3", change1);
|
||||
assertQuery(str + ":<3", change2);
|
||||
assertQuery(str + ":<=2", change2);
|
||||
for (String str : Lists.newArrayList("delta:", "size:")) {
|
||||
assertQuery(str + "<2");
|
||||
assertQuery(str + "3", change1);
|
||||
assertQuery(str + ">2", change1);
|
||||
assertQuery(str + ">=3", change1);
|
||||
assertQuery(str + "<3", change2);
|
||||
assertQuery(str + "<=2", change2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1563,6 +1584,28 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
assertQuery(commit.getId().getName().substring(0, 6), change);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void visible() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
Change change1 = insert(repo, newChange(repo));
|
||||
Change change2 = insert(repo, newChange(repo));
|
||||
|
||||
gApi.changes().id(change2.getChangeId()).setPrivate(true, "private");
|
||||
|
||||
String q = "project:repo";
|
||||
assertQuery(q, change2, change1);
|
||||
|
||||
// Second user cannot see first user's private change.
|
||||
Account.Id user2 =
|
||||
accountManager.authenticate(AuthRequest.forUser("anotheruser")).getAccountId();
|
||||
assertQuery(q + " visibleto:" + user2.get(), change1);
|
||||
|
||||
requestContext.setContext(
|
||||
newRequestContext(
|
||||
accountManager.authenticate(AuthRequest.forUser("anotheruser")).getAccountId()));
|
||||
assertQuery("is:visible", change1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byCommentBy() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
@ -1792,6 +1835,26 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
assertQuery("conflicts:" + change4.getId().get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergeable() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
RevCommit commit1 = repo.parseBody(repo.commit().add("file1", "contents1").create());
|
||||
RevCommit commit2 = repo.parseBody(repo.commit().add("file1", "contents2").create());
|
||||
Change change1 = insert(repo, newChangeForCommit(repo, commit1));
|
||||
Change change2 = insert(repo, newChangeForCommit(repo, commit2));
|
||||
|
||||
assertQuery("conflicts:" + change1.getId().get(), change2);
|
||||
assertQuery("conflicts:" + change2.getId().get(), change1);
|
||||
assertQuery("is:mergeable", change2, change1);
|
||||
|
||||
gApi.changes().id(change1.getChangeId()).revision("current").review(ReviewInput.approve());
|
||||
gApi.changes().id(change1.getChangeId()).revision("current").submit();
|
||||
|
||||
assertQuery("status:open conflicts:" + change2.getId().get());
|
||||
assertQuery("status:open is:mergeable");
|
||||
assertQuery("status:open -is:mergeable", change2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reviewedBy() throws Exception {
|
||||
resetTimeWithClockStep(2, MINUTES);
|
||||
@ -1839,6 +1902,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
Change change1 = insert(repo, newChange(repo));
|
||||
Change change2 = insert(repo, newChange(repo));
|
||||
Change change3 = insert(repo, newChange(repo));
|
||||
insert(repo, newChange(repo));
|
||||
|
||||
AddReviewerInput rin = new AddReviewerInput();
|
||||
@ -1851,15 +1915,48 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
rin.state = ReviewerState.CC;
|
||||
gApi.changes().id(change2.getId().get()).addReviewer(rin);
|
||||
|
||||
assertQuery("is:reviewer");
|
||||
assertQuery("reviewer:self");
|
||||
gApi.changes().id(change3.getChangeId()).revision("current").review(ReviewInput.recommend());
|
||||
assertQuery("is:reviewer", change3);
|
||||
assertQuery("reviewer:self", change3);
|
||||
|
||||
requestContext.setContext(newRequestContext(user1));
|
||||
if (notesMigration.readChanges()) {
|
||||
assertQuery("reviewer:" + user1, change1);
|
||||
assertQuery("cc:" + user1, change2);
|
||||
assertQuery("is:cc", change2);
|
||||
assertQuery("cc:self", change2);
|
||||
} else {
|
||||
assertQuery("reviewer:" + user1, change2, change1);
|
||||
assertQuery("cc:" + user1);
|
||||
assertQuery("is:cc");
|
||||
assertQuery("cc:self");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byReviewed() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
Account.Id otherUser =
|
||||
accountManager.authenticate(AuthRequest.forUser("anotheruser")).getAccountId();
|
||||
Change change1 = insert(repo, newChange(repo));
|
||||
Change change2 = insert(repo, newChange(repo));
|
||||
|
||||
assertQuery("is:reviewed");
|
||||
assertQuery("status:reviewed");
|
||||
assertQuery("-is:reviewed", change2, change1);
|
||||
assertQuery("-status:reviewed", change2, change1);
|
||||
|
||||
requestContext.setContext(newRequestContext(otherUser));
|
||||
gApi.changes().id(change1.getChangeId()).current().review(ReviewInput.recommend());
|
||||
|
||||
assertQuery("is:reviewed", change1);
|
||||
assertQuery("status:reviewed", change1);
|
||||
assertQuery("-is:reviewed", change2);
|
||||
assertQuery("-status:reviewed", change2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reviewerin() throws Exception {
|
||||
Account.Id user1 = accountManager.authenticate(AuthRequest.forUser("user1")).getAccountId();
|
||||
@ -1899,6 +1996,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
gApi.changes().id(change2.getId().get()).current().submit();
|
||||
|
||||
assertQuery("reviewerin:" + group);
|
||||
assertQuery("project:repo reviewerin:" + group, change2);
|
||||
assertQuery("status:merged reviewerin:" + group, change2);
|
||||
}
|
||||
|
||||
@ -2016,6 +2114,10 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
// NEED records don't have associated users.
|
||||
assertQuery("label:CodE-RevieW=need,user1");
|
||||
assertQuery("label:CodE-RevieW=need,user");
|
||||
|
||||
gApi.changes().id(change1.getId().get()).current().submit();
|
||||
assertQuery("submittable:ok");
|
||||
assertQuery("submittable:closed", change1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -2692,6 +2794,89 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
mergedOwned);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignee() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
Change change1 = insert(repo, newChange(repo));
|
||||
Change change2 = insert(repo, newChange(repo));
|
||||
|
||||
AssigneeInput input = new AssigneeInput();
|
||||
input.assignee = user.getUserName().get();
|
||||
gApi.changes().id(change1.getChangeId()).setAssignee(input);
|
||||
|
||||
assertQuery("is:assigned", change1);
|
||||
assertQuery("-is:assigned", change2);
|
||||
assertQuery("is:unassigned", change2);
|
||||
assertQuery("-is:unassigned", change1);
|
||||
assertQuery("assignee:" + user.getUserName().get(), change1);
|
||||
assertQuery("-assignee:" + user.getUserName().get(), change2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userDestination() throws Exception {
|
||||
TestRepository<Repo> repo1 = createProject("repo1");
|
||||
Change change1 = insert(repo1, newChange(repo1));
|
||||
TestRepository<Repo> repo2 = createProject("repo2");
|
||||
Change change2 = insert(repo2, newChange(repo2));
|
||||
|
||||
assertThatQueryException("destination:foo")
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Unknown named destination: foo");
|
||||
|
||||
String destination1 = "refs/heads/master\trepo1";
|
||||
String destination2 = "refs/heads/master\trepo2";
|
||||
String destination3 = "refs/heads/master\trepo1\nrefs/heads/master\trepo2";
|
||||
String destination4 = "refs/heads/master\trepo3";
|
||||
String destination5 = "refs/heads/other\trepo1";
|
||||
|
||||
TestRepository<Repo> allUsers = new TestRepository<>(repoManager.openRepository(allUsersName));
|
||||
String refsUsers = RefNames.refsUsers(userId);
|
||||
allUsers.branch(refsUsers).commit().add("destinations/destination1", destination1).create();
|
||||
allUsers.branch(refsUsers).commit().add("destinations/destination2", destination2).create();
|
||||
allUsers.branch(refsUsers).commit().add("destinations/destination3", destination3).create();
|
||||
allUsers.branch(refsUsers).commit().add("destinations/destination4", destination4).create();
|
||||
allUsers.branch(refsUsers).commit().add("destinations/destination5", destination5).create();
|
||||
|
||||
Ref userRef = allUsers.getRepository().exactRef(refsUsers);
|
||||
assertThat(userRef).isNotNull();
|
||||
|
||||
assertQuery("destination:destination1", change1);
|
||||
assertQuery("destination:destination2", change2);
|
||||
assertQuery("destination:destination3", change2, change1);
|
||||
assertQuery("destination:destination4");
|
||||
assertQuery("destination:destination5");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userQuery() throws Exception {
|
||||
TestRepository<Repo> repo = createProject("repo");
|
||||
Change change1 = insert(repo, newChange(repo));
|
||||
Change change2 = insert(repo, newChangeForBranch(repo, "stable"));
|
||||
|
||||
String queries =
|
||||
"query1\tproject:repo\n"
|
||||
+ "query2\tproject:repo status:open\n"
|
||||
+ "query3\tproject:repo branch:stable\n"
|
||||
+ "query4\tproject:repo branch:other";
|
||||
|
||||
TestRepository<Repo> allUsers = new TestRepository<>(repoManager.openRepository(allUsersName));
|
||||
String refsUsers = RefNames.refsUsers(userId);
|
||||
allUsers.branch(refsUsers).commit().add("queries", queries).create();
|
||||
|
||||
Ref userRef = allUsers.getRepository().exactRef(refsUsers);
|
||||
assertThat(userRef).isNotNull();
|
||||
|
||||
assertThatQueryException("query:foo").hasMessageThat().isEqualTo("Unknown named query: foo");
|
||||
|
||||
assertQuery("query:query1", change2, change1);
|
||||
assertQuery("query:query2", change2, change1);
|
||||
gApi.changes().id(change1.getChangeId()).revision("current").review(ReviewInput.approve());
|
||||
gApi.changes().id(change1.getChangeId()).revision("current").submit();
|
||||
assertQuery("query:query2", change2);
|
||||
assertQuery("query:query3", change2);
|
||||
assertQuery("query:query4");
|
||||
}
|
||||
|
||||
protected ChangeInserter newChange(TestRepository<Repo> repo) throws Exception {
|
||||
return newChange(repo, null, null, null, null, false);
|
||||
}
|
||||
@ -2817,6 +3002,14 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
||||
return new TestRepository<>(repoManager.openRepository(new Project.NameKey(name)));
|
||||
}
|
||||
|
||||
protected TestRepository<Repo> createProject(String name, String parent) throws Exception {
|
||||
ProjectInput input = new ProjectInput();
|
||||
input.name = name;
|
||||
input.parent = parent;
|
||||
gApi.projects().create(input).get();
|
||||
return new TestRepository<>(repoManager.openRepository(new Project.NameKey(name)));
|
||||
}
|
||||
|
||||
protected QueryRequest newQuery(Object query) {
|
||||
return gApi.changes().query(query.toString());
|
||||
}
|
||||
|
@ -1,13 +1,19 @@
|
||||
java_plugin(
|
||||
name = "auto-annotation-plugin",
|
||||
processor_class = "com.google.auto.value.processor.AutoAnnotationProcessor",
|
||||
deps = ["@auto_value//jar"],
|
||||
deps = [
|
||||
"@auto_value//jar",
|
||||
"@auto_value_annotations//jar",
|
||||
],
|
||||
)
|
||||
|
||||
java_plugin(
|
||||
name = "auto-value-plugin",
|
||||
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
|
||||
deps = ["@auto_value//jar"],
|
||||
deps = [
|
||||
"@auto_value//jar",
|
||||
"@auto_value_annotations//jar",
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
@ -20,3 +26,14 @@ java_library(
|
||||
visibility = ["//visibility:public"],
|
||||
exports = ["@auto_value//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "auto-value-annotations",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exported_plugins = [
|
||||
":auto-annotation-plugin",
|
||||
":auto-value-plugin",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
exports = ["@auto_value_annotations//jar"],
|
||||
)
|
||||
|
@ -7,7 +7,6 @@ java_library(
|
||||
runtime_deps = [
|
||||
":compress-lzf",
|
||||
":hppc",
|
||||
":jna",
|
||||
":joda-time",
|
||||
":jsr166e",
|
||||
":netty",
|
||||
@ -15,12 +14,10 @@ java_library(
|
||||
"//lib/jackson:jackson-core",
|
||||
"//lib/jackson:jackson-dataformat-cbor",
|
||||
"//lib/jackson:jackson-dataformat-smile",
|
||||
"//lib/lucene:lucene-codecs",
|
||||
"//lib/lucene:lucene-highlighter",
|
||||
"//lib/lucene:lucene-join",
|
||||
"//lib/lucene:lucene-memory",
|
||||
"//lib/lucene:lucene-queries",
|
||||
"//lib/lucene:lucene-sandbox",
|
||||
"//lib/lucene:lucene-spatial",
|
||||
"//lib/lucene:lucene-suggest",
|
||||
],
|
||||
@ -73,9 +70,3 @@ java_library(
|
||||
visibility = ["//lib/elasticsearch:__pkg__"],
|
||||
exports = ["@t_digest//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "jna",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@jna//jar"],
|
||||
)
|
||||
|
@ -45,9 +45,3 @@ java_library(
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@httpcore_nio//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "httpcore-niossl",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@httpcore_niossl//jar"],
|
||||
)
|
||||
|
@ -8,14 +8,14 @@ java_library(
|
||||
exports = ["@jackson_core//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "jackson-dataformat-smile",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@jackson_dataformat_smile//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "jackson-dataformat-cbor",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@jackson_dataformat_cbor//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "jackson-dataformat-smile",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@jackson_dataformat_smile//jar"],
|
||||
)
|
||||
|
@ -5,6 +5,9 @@ java_library(
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
visibility = ["//visibility:public"],
|
||||
exports = ["@jest_common//jar"],
|
||||
runtime_deps = [
|
||||
"//lib/commons:lang3",
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
@ -13,11 +16,8 @@ java_library(
|
||||
visibility = ["//visibility:public"],
|
||||
exports = ["@jest//jar"],
|
||||
runtime_deps = [
|
||||
":jest-common",
|
||||
"//lib/commons:lang3",
|
||||
"//lib/httpcomponents:httpasyncclient",
|
||||
"//lib/httpcomponents:httpclient",
|
||||
"//lib/httpcomponents:httpcore-nio",
|
||||
"//lib/httpcomponents:httpcore-niossl",
|
||||
],
|
||||
)
|
||||
|
@ -22,13 +22,6 @@ java_library(
|
||||
runtime_deps = [":lucene-core-and-backward-codecs"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "lucene-codecs",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
visibility = ["//visibility:public"],
|
||||
exports = ["@lucene_codecs//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "lucene-core",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
@ -70,12 +63,6 @@ java_library(
|
||||
exports = ["@lucene_memory//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "lucene-sandbox",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
exports = ["@lucene_sandbox//jar"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "lucene-spatial",
|
||||
data = ["//lib:LICENSE-Apache2.0"],
|
||||
|
Loading…
Reference in New Issue
Block a user