Merge "Move TimeUtil into own package and let it have its own java_library"
diff --git a/Documentation/access-control.txt b/Documentation/access-control.txt
index 56200c4..d3f5d77 100644
--- a/Documentation/access-control.txt
+++ b/Documentation/access-control.txt
@@ -1583,15 +1583,18 @@
* The 'force' setting has no effect on label ranges.
* BLOCK specifies the values that a group cannot vote, eg.
++
----
label-Code-Review = block -2..+2 group Anonymous Users
----
++
prevents all users from voting -2 or +2.
* DENY works for votes too, with the same caveats
* The blocked vote range is the union of the all the blocked vote
ranges across projects, so in
++
----
All-Projects: project.config
label-Code-Review = block -2..+1 group A
@@ -1599,15 +1602,18 @@
Child-Project: project-config
label-Code-Review = block -1..+2 group A
----
++
members of group A cannot vote at all in the Child-Project.
* The allowed vote range is the union of vote ranges allowed by all of
the ALLOW rules. For example, in
++
----
label-Code-Review = -2..+1 group A
label-Code-Review = -1..+2 group B
----
++
a user that is both in A and B can vote -2..2.
diff --git a/Documentation/cmd-index.txt b/Documentation/cmd-index.txt
index 496c205..25099fa 100644
--- a/Documentation/cmd-index.txt
+++ b/Documentation/cmd-index.txt
@@ -8,11 +8,11 @@
To download a client command or hook, use scp or an http client:
----
- $ scp -p -P 29418 john.doe@review.example.com:bin/gerrit-cherry-pick ~/bin/
- $ scp -p -P 29418 john.doe@review.example.com:hooks/commit-msg .git/hooks/
+$ scp -p -P 29418 john.doe@review.example.com:bin/gerrit-cherry-pick ~/bin/
+$ scp -p -P 29418 john.doe@review.example.com:hooks/commit-msg .git/hooks/
- $ curl -Lo ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick
- $ curl -Lo .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg
+$ curl -Lo ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick
+$ curl -Lo .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg
----
For more details on how to determine the correct SSH port number,
@@ -32,7 +32,7 @@
server.
link:cmd-hook-commit-msg.html[commit-msg]::
- Automatically generate `Change-Id: ` tags in commit messages.
+ Automatically generate `Change-Id:` tags in commit messages.
== Server
diff --git a/Documentation/config-accounts.txt b/Documentation/config-accounts.txt
index 6378632..51d8cec 100644
--- a/Documentation/config-accounts.txt
+++ b/Documentation/config-accounts.txt
@@ -296,6 +296,11 @@
an external ID is used only once (e.g. an external ID can never be
assigned to multiple accounts at a point in time).
+[IMPORTANT]
+If the external ID key is changed manually you must adapt the note key
+to the new SHA1. Otherwise the external ID becomes inconsistent and is
+ignored by Gerrit.
+
The note content is a Git config file:
----
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 0108a04..734397e 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -616,7 +616,10 @@
existing accounts this username is already in lower case. It is not
possible to convert the usernames of the existing accounts to lower
case because this would break the access to existing per-user
-branches.
+branches and Gerrit provides no tool to do such a conversion.
++
+Setting this parameter to `true` will prevent all users from login that
+have a non-lower-case username.
+
This parameter only affects git over http and git over SSH traffic.
+
@@ -2983,8 +2986,8 @@
=== Section elasticsearch
WARNING: Support for Elasticsearch is still experimental and is not recommended
-for production use. Support has been tested with Elasticsearch versions 2.4, 5.6,
-6.2 and 6.3. Support for other versions is not guaranteed.
+for production use. For compatibility information, please refer to the
+link:https://www.gerritcodereview.com/elasticsearch.html[project homepage].
When using Elasticsearch versions 2.4 and 5.6, the open and closed changes are
indexed in a single index, separated into types `open_changes` and `closed_changes`
@@ -3034,6 +3037,7 @@
* link:https://www.elastic.co/guide/en/x-pack/5.6/security-getting-started.html[Elasticsearch 5.6]
* link:https://www.elastic.co/guide/en/x-pack/6.2/security-getting-started.html[Elasticsearch 6.2]
* link:https://www.elastic.co/guide/en/elastic-stack-overview/6.3/security-getting-started.html[Elasticsearch 6.3]
+* link:https://www.elastic.co/guide/en/elastic-stack-overview/6.4/security-getting-started.html[Elasticsearch 6.4]
[[elasticsearch.username]]elasticsearch.username::
+
diff --git a/Documentation/intro-how-gerrit-works.txt b/Documentation/intro-how-gerrit-works.txt
index 2df42d4..5f5deed 100644
--- a/Documentation/intro-how-gerrit-works.txt
+++ b/Documentation/intro-how-gerrit-works.txt
@@ -1,32 +1,33 @@
= How Gerrit Works
-To learn how Gerrit fits into and complements the developer workflow, consider a
-typical project. The following project contains a central source repository
+To learn how Gerrit fits into and complements the developer workflow, consider
+a typical project. The following project contains a central source repository
(_Authoritative Repository_) that serves as the authoritative version of the
project's contents.
-.Central Source Repository image::images/intro-quick-central-
-repo.png[Authoritative Source Repository]
+.Central Source Repository
+image::images/intro-quick-central-repo.png[Authoritative Source Repository]
-When implemented, Gerrit becomes the central source repository and introduces an
-additional concept: a store of _Pending Changes_.
+When implemented, Gerrit becomes the central source repository and introduces
+an additional concept: a store of _Pending Changes_.
-.Gerrit as the Central Repository image::images/intro-quick-central-
-gerrit.png[Gerrit in place of Central Repository]
+.Gerrit as the Central Repository
+image::images/intro-quick-central-gerrit.png[Gerrit as the Central Repository]
-When Gerrit is configured as the central source repository, all code changes are
-sent to Pending Changes for others to review and discuss. When enough reviewers
-have approved a code change, you can submit the change to the code base.
+When Gerrit is configured as the central source repository, all code changes
+are sent to Pending Changes for others to review and discuss. When enough
+reviewers have approved a code change, you can submit the change to the code
+base.
In addition to the store of Pending Changes, Gerrit captures notes and comments
made about each change. This enables you to review changes at your convenience
-or when a conversation about a change can't happen in person. In addition, notes
-and comments provide a history of each change (what was changed and why and who
-reviewed the change).
+or when a conversation about a change can't happen in person. In addition,
+notes and comments provide a history of each change (what was changed and why and
+who reviewed the change).
-Like any repository hosting product, Gerrit provides a powerful link:access-
-control.html[access control model], which enables you to fine-tune access to
-your repository.
+Like any repository hosting product, Gerrit provides a powerful
+link:access-control.html[access control model], which enables you to
+fine-tune access to your repository.
GERRIT
------
diff --git a/Documentation/pgm-LocalUsernamesToLowerCase.txt b/Documentation/pgm-LocalUsernamesToLowerCase.txt
index 03aaabf..4b50961 100644
--- a/Documentation/pgm-LocalUsernamesToLowerCase.txt
+++ b/Documentation/pgm-LocalUsernamesToLowerCase.txt
@@ -14,7 +14,11 @@
== DESCRIPTION
Converts the local username for every account to lower case. The
local username is the username that is used to login into the Gerrit
-Web UI.
+Web UI. The local username is stored a external ID with scheme
+`gerrit`.
+
+[IMPORTANT]
+This program does not modify usernames in the `username` scheme.
This task is only intended to be run if the configuration parameter
link:config-gerrit.html#ldap.localUsernameToLowerCase[ldap.localUsernameToLowerCase]
diff --git a/WORKSPACE b/WORKSPACE
index dca68d3..68d7aeb 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,5 +1,6 @@
workspace(name = "gerrit")
+load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "maven_jar")
load("//lib/codemirror:cm.bzl", "CM_VERSION", "DIFF_MATCH_PATCH_VERSION")
@@ -30,7 +31,7 @@
load("@bazel_skylib//:lib.bzl", "versions")
-versions.check(minimum_bazel_version = "0.14.0")
+versions.check(minimum_bazel_version = "0.17.1")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
@@ -43,6 +44,42 @@
omit_javax_inject = True,
)
+# Golang support for PolyGerrit local dev server.
+http_archive(
+ name = "io_bazel_rules_go",
+ sha256 = "97cf62bdef33519412167fd1e4b0810a318a7c234f5f8dc4f53e2da86241c492",
+ urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.15.3/rules_go-0.15.3.tar.gz"],
+)
+
+load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
+
+go_rules_dependencies()
+
+go_register_toolchains()
+
+http_archive(
+ name = "bazel_gazelle",
+ sha256 = "c0a5739d12c6d05b6c1ad56f2200cb0b57c5a70e03ebd2f7b87ce88cabf09c7b",
+ urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.14.0/bazel-gazelle-0.14.0.tar.gz"],
+)
+
+load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
+
+gazelle_dependencies()
+
+# Dependencies for PolyGerrit local dev server.
+go_repository(
+ name = "com_github_robfig_soy",
+ commit = "82face14ebc0883b4ca9c901b5aaf3738b9f6a24",
+ importpath = "github.com/robfig/soy",
+)
+
+go_repository(
+ name = "com_github_howeyc_fsnotify",
+ commit = "441bbc86b167f3c1f4786afae9931403b99fdacf",
+ importpath = "github.com/howeyc/fsnotify",
+)
+
ANTLR_VERS = "3.5.2"
maven_jar(
@@ -918,60 +955,60 @@
sha1 = "df4b50061e8e4c348ce243b921f53ee63ba9bbe1",
)
-JETTY_VERS = "9.3.18.v20170406"
+JETTY_VERS = "9.4.12.v20180830"
maven_jar(
name = "jetty-servlet",
artifact = "org.eclipse.jetty:jetty-servlet:" + JETTY_VERS,
- sha1 = "534e7fa0e4fb6e08f89eb3f6a8c48b4f81ff5738",
+ sha1 = "4c1149328eda9fa39a274262042420f66d9ffd5f",
)
maven_jar(
name = "jetty-security",
artifact = "org.eclipse.jetty:jetty-security:" + JETTY_VERS,
- sha1 = "16b900e91b04511f42b706c925c8af6023d2c05e",
+ sha1 = "299e0602a9c0b753ba232cc1c1dda72ddd9addcf",
)
maven_jar(
name = "jetty-servlets",
artifact = "org.eclipse.jetty:jetty-servlets:" + JETTY_VERS,
- sha1 = "f9311d1d8e6124d2792f4db5b29514d0ecf46812",
+ sha1 = "53745200718fe4ddf57f04ad3ba34778a6aca585",
)
maven_jar(
name = "jetty-server",
artifact = "org.eclipse.jetty:jetty-server:" + JETTY_VERS,
- sha1 = "0a32feea88cba2d43951d22b60861c643454bb3f",
+ sha1 = "b0f25df0d32a445fd07d5f16fff1411c16b888fa",
)
maven_jar(
name = "jetty-jmx",
artifact = "org.eclipse.jetty:jetty-jmx:" + JETTY_VERS,
- sha1 = "f988136dc5aa634afed6c5a35d910ee9599c6c23",
+ sha1 = "7e9e589dd749a8c096008c0c4af863a81e67c55b",
)
maven_jar(
name = "jetty-continuation",
artifact = "org.eclipse.jetty:jetty-continuation:" + JETTY_VERS,
- sha1 = "3c5d89c8204d4a48a360087f95e4cbd4520b5de0",
+ sha1 = "5f6d6e06f95088a3a7118b9065bc49ce7c014b75",
)
maven_jar(
name = "jetty-http",
artifact = "org.eclipse.jetty:jetty-http:" + JETTY_VERS,
- sha1 = "30ece6d732d276442d513b94d914de6fa1075fae",
+ sha1 = "1341796dde4e16df69bca83f3e87688ba2e7d703",
)
maven_jar(
name = "jetty-io",
artifact = "org.eclipse.jetty:jetty-io:" + JETTY_VERS,
- sha1 = "36cb411ee89be1b527b0c10747aa3153267fc3ec",
+ sha1 = "e93f5adaa35a9a6a85ba130f589c5305c6ecc9e3",
)
maven_jar(
name = "jetty-util",
artifact = "org.eclipse.jetty:jetty-util:" + JETTY_VERS,
- sha1 = "8600b7d028a38cb462eff338de91390b3ff5040e",
+ sha1 = "cb4ccec9bd1fe4b10a04a0fb25d7053c1050188a",
)
maven_jar(
@@ -1038,8 +1075,8 @@
maven_jar(
name = "elasticsearch-rest-client",
- artifact = "org.elasticsearch.client:elasticsearch-rest-client:6.4.0",
- sha1 = "0eaa13decb9796eb671c5841d0770ae68b348da5",
+ artifact = "org.elasticsearch.client:elasticsearch-rest-client:6.4.1",
+ sha1 = "b5b52703e8d798a71e1269c2eda585dff720436f",
)
JACKSON_VERSION = "2.8.9"
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchedProjectsScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchedProjectsScreen.java
index c99cd1a..f29b573 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchedProjectsScreen.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/account/MyWatchedProjectsScreen.java
@@ -182,11 +182,6 @@
return;
}
- String filter = filterTxt.getText();
- if (filter == null || filter.isEmpty() || filter.equals(Util.C.defaultFilter())) {
- filter = null;
- }
-
addNew.setEnabled(false);
nameBox.setEnabled(false);
filterTxt.setEnabled(false);
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/LocalComments.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/LocalComments.java
index 44652cf..d2f031a 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/LocalComments.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/LocalComments.java
@@ -201,8 +201,8 @@
private static InlineComment getInlineComment(String key) {
String path;
- Side side = Side.PARENT;
- int line = 0;
+ Side side;
+ int line;
CommentRange range;
StorageBackend storage = new StorageBackend();
diff --git a/java/com/google/gerrit/acceptance/GerritServer.java b/java/com/google/gerrit/acceptance/GerritServer.java
index 582c7cb..3bf17e4 100644
--- a/java/com/google/gerrit/acceptance/GerritServer.java
+++ b/java/com/google/gerrit/acceptance/GerritServer.java
@@ -265,9 +265,6 @@
public static GerritServer initAndStart(
Description desc, Config baseConfig, @Nullable Module testSysModule) throws Exception {
Path site = TempFileUtil.createTempDirectory().toPath();
- baseConfig = new Config(baseConfig);
- baseConfig.setString("gerrit", null, "basePath", site.resolve("git").toString());
- baseConfig.setString("gerrit", null, "tempSiteDir", site.toString());
try {
if (!desc.memory()) {
init(desc, baseConfig, site);
diff --git a/java/com/google/gerrit/acceptance/ProjectResetter.java b/java/com/google/gerrit/acceptance/ProjectResetter.java
index 1fed8f8..76ae4b0 100644
--- a/java/com/google/gerrit/acceptance/ProjectResetter.java
+++ b/java/com/google/gerrit/acceptance/ProjectResetter.java
@@ -214,7 +214,7 @@
for (Map.Entry<Project.NameKey, Collection<String>> e :
refsPatternByProject.asMap().entrySet()) {
try (Repository repo = repoManager.openRepository(e.getKey())) {
- Collection<Ref> refs = repo.getAllRefs().values();
+ Collection<Ref> refs = repo.getRefDatabase().getRefs();
for (String refPattern : e.getValue()) {
RefPatternMatcher matcher = RefPatternMatcher.getMatcher(refPattern);
for (Ref ref : refs) {
diff --git a/java/com/google/gerrit/common/data/GlobalCapability.java b/java/com/google/gerrit/common/data/GlobalCapability.java
index e613d21..3e11256 100644
--- a/java/com/google/gerrit/common/data/GlobalCapability.java
+++ b/java/com/google/gerrit/common/data/GlobalCapability.java
@@ -90,6 +90,9 @@
/** Default result limit per executed query. */
public static final int DEFAULT_MAX_QUERY_LIMIT = 500;
+ /** Can impersonate any user to see which refs they can read. */
+ public static final String READ_AS = "readAs";
+
/** Ability to impersonate another user. */
public static final String RUN_AS = "runAs";
@@ -138,6 +141,7 @@
NAMES_ALL.add(MODIFY_ACCOUNT);
NAMES_ALL.add(PRIORITY);
NAMES_ALL.add(QUERY_LIMIT);
+ NAMES_ALL.add(READ_AS);
NAMES_ALL.add(RUN_AS);
NAMES_ALL.add(RUN_GC);
NAMES_ALL.add(STREAM_EVENTS);
diff --git a/java/com/google/gerrit/httpd/BUILD b/java/com/google/gerrit/httpd/BUILD
index dd0c17f..2294d0e 100644
--- a/java/com/google/gerrit/httpd/BUILD
+++ b/java/com/google/gerrit/httpd/BUILD
@@ -2,7 +2,10 @@
name = "httpd",
srcs = glob(["**/*.java"]),
resource_strip_prefix = "resources",
- resources = ["//resources/com/google/gerrit/httpd"],
+ resources = [
+ "//resources/com/google/gerrit/httpd",
+ "//resources/com/google/gerrit/httpd/raw",
+ ],
visibility = ["//visibility:public"],
deps = [
"//java/com/google/gerrit/common:annotations",
diff --git a/java/com/google/gerrit/httpd/ProjectOAuthFilter.java b/java/com/google/gerrit/httpd/ProjectOAuthFilter.java
index 589448e..5e234d2e 100644
--- a/java/com/google/gerrit/httpd/ProjectOAuthFilter.java
+++ b/java/com/google/gerrit/httpd/ProjectOAuthFilter.java
@@ -118,7 +118,7 @@
}
private boolean verify(HttpServletRequest req, Response rsp) throws IOException {
- AuthInfo authInfo = null;
+ AuthInfo authInfo;
// first check if there is a BASIC authentication header
String hdr = req.getHeader(AUTHORIZATION);
diff --git a/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java b/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java
index a1a6715..a51a0ab 100644
--- a/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java
+++ b/java/com/google/gerrit/httpd/auth/openid/OAuthSessionOverOpenID.java
@@ -120,7 +120,7 @@
com.google.gerrit.server.account.AuthRequest areq =
new com.google.gerrit.server.account.AuthRequest(
ExternalId.Key.parse(user.getExternalId()));
- AuthResult arsp = null;
+ AuthResult arsp;
try {
String claimedIdentifier = user.getClaimedIdentity();
Optional<Account.Id> actualId = accountManager.lookup(user.getExternalId());
diff --git a/java/com/google/gerrit/httpd/raw/IndexServlet.java b/java/com/google/gerrit/httpd/raw/IndexServlet.java
index 90b25d9..a414e84 100644
--- a/java/com/google/gerrit/httpd/raw/IndexServlet.java
+++ b/java/com/google/gerrit/httpd/raw/IndexServlet.java
@@ -37,7 +37,8 @@
private static final long serialVersionUID = 1L;
protected final byte[] indexSource;
- IndexServlet(String canonicalURL, @Nullable String cdnPath, @Nullable String faviconPath)
+ IndexServlet(
+ @Nullable String canonicalURL, @Nullable String cdnPath, @Nullable String faviconPath)
throws URISyntaxException {
String resourcePath = "com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy";
SoyFileSet.Builder builder = SoyFileSet.builder();
@@ -62,7 +63,7 @@
}
}
- static String computeCanonicalPath(String canonicalURL) throws URISyntaxException {
+ static String computeCanonicalPath(@Nullable String canonicalURL) throws URISyntaxException {
if (Strings.isNullOrEmpty(canonicalURL)) {
return "";
}
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index 0be7ccd..6b5fce1 100644
--- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -445,6 +445,7 @@
}
if (notModified(req, rsrc, viewData.view)) {
+ logger.atFinest().log("REST call succeeded: %d", SC_NOT_MODIFIED);
res.sendError(SC_NOT_MODIFIED);
return;
}
diff --git a/java/com/google/gerrit/pgm/http/jetty/ProjectQoSFilter.java b/java/com/google/gerrit/pgm/http/jetty/ProjectQoSFilter.java
index 96cf7be..9354209 100644
--- a/java/com/google/gerrit/pgm/http/jetty/ProjectQoSFilter.java
+++ b/java/com/google/gerrit/pgm/http/jetty/ProjectQoSFilter.java
@@ -61,6 +61,7 @@
* Jetty's HTTP parser to crash, so we instead block the SSH execution queue thread and ask Jetty to
* resume processing on the web service thread.
*/
+@SuppressWarnings("deprecation")
@Singleton
public class ProjectQoSFilter implements Filter {
private static final String ATT_SPACE = ProjectQoSFilter.class.getName();
diff --git a/java/com/google/gerrit/server/account/CapabilityCollection.java b/java/com/google/gerrit/server/account/CapabilityCollection.java
index ee74f47..1abc33f 100644
--- a/java/com/google/gerrit/server/account/CapabilityCollection.java
+++ b/java/com/google/gerrit/server/account/CapabilityCollection.java
@@ -48,6 +48,7 @@
public final ImmutableList<PermissionRule> batchChangesLimit;
public final ImmutableList<PermissionRule> emailReviewers;
public final ImmutableList<PermissionRule> priority;
+ public final ImmutableList<PermissionRule> readAs;
public final ImmutableList<PermissionRule> queryLimit;
public final ImmutableList<PermissionRule> createGroup;
@@ -97,6 +98,7 @@
batchChangesLimit = getPermission(GlobalCapability.BATCH_CHANGES_LIMIT);
emailReviewers = getPermission(GlobalCapability.EMAIL_REVIEWERS);
priority = getPermission(GlobalCapability.PRIORITY);
+ readAs = getPermission(GlobalCapability.READ_AS);
queryLimit = getPermission(GlobalCapability.QUERY_LIMIT);
createGroup = getPermission(GlobalCapability.CREATE_GROUP);
}
diff --git a/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java b/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
index 164d39c..a538897 100644
--- a/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
+++ b/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
@@ -543,7 +543,7 @@
try (Statement s = c.conn.createStatement()) {
// Compute size without restricting to version (although obsolete data was just pruned
// anyway).
- long used = 0;
+ long used;
try (ResultSet r = s.executeQuery("SELECT SUM(space) FROM data")) {
used = r.next() ? r.getLong(1) : 0;
}
diff --git a/java/com/google/gerrit/server/change/ChangeJson.java b/java/com/google/gerrit/server/change/ChangeJson.java
index 173d1da..43f7b2f 100644
--- a/java/com/google/gerrit/server/change/ChangeJson.java
+++ b/java/com/google/gerrit/server/change/ChangeJson.java
@@ -1308,7 +1308,7 @@
RevWalk rw = newRevWalk(repo)) {
for (PatchSet in : map.values()) {
PatchSet.Id id = in.getId();
- boolean want = false;
+ boolean want;
if (has(ALL_REVISIONS)) {
want = true;
} else if (limitToPsId.isPresent()) {
diff --git a/java/com/google/gerrit/server/config/CapabilityConstants.java b/java/com/google/gerrit/server/config/CapabilityConstants.java
index 961dbbd..4ab97f8 100644
--- a/java/com/google/gerrit/server/config/CapabilityConstants.java
+++ b/java/com/google/gerrit/server/config/CapabilityConstants.java
@@ -34,6 +34,7 @@
public String maintainServer;
public String modifyAccount;
public String priority;
+ public String readAs;
public String queryLimit;
public String runAs;
public String runGC;
diff --git a/java/com/google/gerrit/server/git/receive/ReplaceOp.java b/java/com/google/gerrit/server/git/receive/ReplaceOp.java
index 3e7942f..2a46f3b 100644
--- a/java/com/google/gerrit/server/git/receive/ReplaceOp.java
+++ b/java/com/google/gerrit/server/git/receive/ReplaceOp.java
@@ -128,7 +128,7 @@
private final PatchSetInfo info;
private final MagicBranchInput magicBranch;
private final PushCertificate pushCertificate;
- private List<String> groups = ImmutableList.of();
+ private List<String> groups;
private final Map<String, Short> approvals = new HashMap<>();
private final MailRecipients recipients = new MailRecipients();
diff --git a/java/com/google/gerrit/server/mail/send/ChangeEmail.java b/java/com/google/gerrit/server/mail/send/ChangeEmail.java
index 4ba3b67..bfb210e 100644
--- a/java/com/google/gerrit/server/mail/send/ChangeEmail.java
+++ b/java/com/google/gerrit/server/mail/send/ChangeEmail.java
@@ -23,7 +23,6 @@
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.mail.MailHeader;
import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -50,7 +49,6 @@
import java.sql.Timestamp;
import java.text.MessageFormat;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -236,15 +234,6 @@
+ ">";
}
- /** Format the sender's "cover letter", {@link #getCoverLetter()}. */
- protected void formatCoverLetter() {
- final String cover = getCoverLetter();
- if (!"".equals(cover)) {
- appendText(cover);
- appendText("\n\n");
- }
- }
-
/** Get the text of the "cover letter". */
public String getCoverLetter() {
if (changeMessage != null) {
@@ -253,11 +242,6 @@
return "";
}
- /** Format the change message and the affected file list. */
- protected void formatChangeDetail() {
- appendText(getChangeDetail());
- }
-
/** Create the change message and the affected file list. */
public String getChangeDetail() {
try {
@@ -314,14 +298,6 @@
return projectState;
}
- /** Get the groups which own the project. */
- protected Set<AccountGroup.UUID> getProjectOwners() {
- final ProjectState r;
-
- r = args.projectCache.get(change.getProject());
- return r != null ? r.getOwners() : Collections.<AccountGroup.UUID>emptySet();
- }
-
/** TO or CC all vested parties (change owner, patch set uploader, author). */
protected void rcptToAuthors(RecipientType rt) {
for (Account.Id id : authors) {
diff --git a/java/com/google/gerrit/server/mail/send/CommentSender.java b/java/com/google/gerrit/server/mail/send/CommentSender.java
index 0baaa11c..e810397 100644
--- a/java/com/google/gerrit/server/mail/send/CommentSender.java
+++ b/java/com/google/gerrit/server/mail/send/CommentSender.java
@@ -507,7 +507,7 @@
@Override
protected void setupSoyContext() {
super.setupSoyContext();
- boolean hasComments = false;
+ boolean hasComments;
try (Repository repo = getRepository()) {
List<Map<String, Object>> files = getCommentGroupsTemplateData(repo);
soyContext.put("commentFiles", files);
diff --git a/java/com/google/gerrit/server/patch/PatchListEntry.java b/java/com/google/gerrit/server/patch/PatchListEntry.java
index 325f78d..6b1a153 100644
--- a/java/com/google/gerrit/server/patch/PatchListEntry.java
+++ b/java/com/google/gerrit/server/patch/PatchListEntry.java
@@ -26,6 +26,7 @@
import static com.google.gerrit.server.ioutil.BasicSerialization.writeFixInt64;
import static com.google.gerrit.server.ioutil.BasicSerialization.writeString;
import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
+import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -41,7 +42,6 @@
import java.util.List;
import java.util.Set;
import org.eclipse.jgit.diff.Edit;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.patch.CombinedFileHeader;
import org.eclipse.jgit.patch.FileHeader;
import org.eclipse.jgit.util.IntList;
@@ -223,7 +223,7 @@
if (header[e - 1] == '\n') {
e--;
}
- headerLines.add(RawParseUtils.decode(Constants.CHARSET, header, b, e));
+ headerLines.add(RawParseUtils.decode(UTF_8, header, b, e));
}
return headerLines;
}
diff --git a/java/com/google/gerrit/server/patch/PatchListLoader.java b/java/com/google/gerrit/server/patch/PatchListLoader.java
index 8301ee6..074e344 100644
--- a/java/com/google/gerrit/server/patch/PatchListLoader.java
+++ b/java/com/google/gerrit/server/patch/PatchListLoader.java
@@ -185,11 +185,11 @@
df.setDetectRenames(true);
List<DiffEntry> diffEntries = df.scan(aTree, bTree);
- Multimap<String, ContextAwareEdit> editsDueToRebasePerFilePath = ImmutableMultimap.of();
EditsDueToRebaseResult editsDueToRebaseResult =
determineEditsDueToRebase(aCommit, b, diffEntries, df, rw);
diffEntries = editsDueToRebaseResult.getRelevantOriginalDiffEntries();
- editsDueToRebasePerFilePath = editsDueToRebaseResult.getEditsDueToRebasePerFilePath();
+ Multimap<String, ContextAwareEdit> editsDueToRebasePerFilePath =
+ editsDueToRebaseResult.getEditsDueToRebasePerFilePath();
List<PatchListEntry> entries = new ArrayList<>();
entries.add(
diff --git a/java/com/google/gerrit/server/permissions/DefaultPermissionBackend.java b/java/com/google/gerrit/server/permissions/DefaultPermissionBackend.java
index 51a0f95..8cf9444 100644
--- a/java/com/google/gerrit/server/permissions/DefaultPermissionBackend.java
+++ b/java/com/google/gerrit/server/permissions/DefaultPermissionBackend.java
@@ -172,6 +172,7 @@
case CREATE_PROJECT:
case MAINTAIN_SERVER:
case MODIFY_ACCOUNT:
+ case READ_AS:
case STREAM_EVENTS:
case VIEW_ALL_ACCOUNTS:
case VIEW_CONNECTIONS:
diff --git a/java/com/google/gerrit/server/permissions/DefaultPermissionMappings.java b/java/com/google/gerrit/server/permissions/DefaultPermissionMappings.java
index 9593521..cee42ad 100644
--- a/java/com/google/gerrit/server/permissions/DefaultPermissionMappings.java
+++ b/java/com/google/gerrit/server/permissions/DefaultPermissionMappings.java
@@ -50,6 +50,7 @@
.put(GlobalPermission.KILL_TASK, GlobalCapability.KILL_TASK)
.put(GlobalPermission.MAINTAIN_SERVER, GlobalCapability.MAINTAIN_SERVER)
.put(GlobalPermission.MODIFY_ACCOUNT, GlobalCapability.MODIFY_ACCOUNT)
+ .put(GlobalPermission.READ_AS, GlobalCapability.READ_AS)
.put(GlobalPermission.RUN_AS, GlobalCapability.RUN_AS)
.put(GlobalPermission.RUN_GC, GlobalCapability.RUN_GC)
.put(GlobalPermission.STREAM_EVENTS, GlobalCapability.STREAM_EVENTS)
diff --git a/java/com/google/gerrit/server/permissions/GlobalPermission.java b/java/com/google/gerrit/server/permissions/GlobalPermission.java
index 01ef725..07c9e84 100644
--- a/java/com/google/gerrit/server/permissions/GlobalPermission.java
+++ b/java/com/google/gerrit/server/permissions/GlobalPermission.java
@@ -43,6 +43,7 @@
KILL_TASK,
MAINTAIN_SERVER,
MODIFY_ACCOUNT,
+ READ_AS,
RUN_AS,
RUN_GC,
STREAM_EVENTS,
diff --git a/java/com/google/gerrit/server/permissions/ProjectControl.java b/java/com/google/gerrit/server/permissions/ProjectControl.java
index 46bf45f..787bee4 100644
--- a/java/com/google/gerrit/server/permissions/ProjectControl.java
+++ b/java/com/google/gerrit/server/permissions/ProjectControl.java
@@ -29,7 +29,6 @@
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
-import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.config.GitReceivePackGroups;
import com.google.gerrit.server.config.GitUploadPackGroups;
@@ -70,7 +69,6 @@
private final ChangeControl.Factory changeControlFactory;
private final PermissionCollection.Factory permissionFilter;
private final DefaultRefFilter.Factory refFilterFactory;
- private final IdentifiedUser.GenericFactory identifiedUserFactory;
private List<SectionMatcher> allSections;
private Map<String, RefControl> refControls;
@@ -84,7 +82,6 @@
ChangeControl.Factory changeControlFactory,
PermissionBackend permissionBackend,
DefaultRefFilter.Factory refFilterFactory,
- IdentifiedUser.GenericFactory identifiedUserFactory,
@Assisted CurrentUser who,
@Assisted ProjectState ps) {
this.changeControlFactory = changeControlFactory;
@@ -93,7 +90,6 @@
this.permissionFilter = permissionFilter;
this.permissionBackend = permissionBackend;
this.refFilterFactory = refFilterFactory;
- this.identifiedUserFactory = identifiedUserFactory;
user = who;
state = ps;
}
@@ -122,7 +118,7 @@
RefControl ctl = refControls.get(refName);
if (ctl == null) {
PermissionCollection relevant = permissionFilter.filter(access(), refName, user);
- ctl = new RefControl(identifiedUserFactory, this, refName, relevant);
+ ctl = new RefControl(this, refName, relevant);
refControls.put(refName, ctl);
}
return ctl;
diff --git a/java/com/google/gerrit/server/permissions/RefControl.java b/java/com/google/gerrit/server/permissions/RefControl.java
index b324e77..a3c8de5 100644
--- a/java/com/google/gerrit/server/permissions/RefControl.java
+++ b/java/com/google/gerrit/server/permissions/RefControl.java
@@ -27,7 +27,6 @@
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.CurrentUser;
-import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.permissions.PermissionBackend.ForChange;
import com.google.gerrit.server.permissions.PermissionBackend.ForRef;
@@ -44,7 +43,6 @@
class RefControl {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- private final IdentifiedUser.GenericFactory identifiedUserFactory;
private final ProjectControl projectControl;
private final String refName;
@@ -58,12 +56,7 @@
private Boolean canForgeCommitter;
private Boolean isVisible;
- RefControl(
- IdentifiedUser.GenericFactory identifiedUserFactory,
- ProjectControl projectControl,
- String ref,
- PermissionCollection relevant) {
- this.identifiedUserFactory = identifiedUserFactory;
+ RefControl(ProjectControl projectControl, String ref, PermissionCollection relevant) {
this.projectControl = projectControl;
this.refName = ref;
this.relevant = relevant;
diff --git a/java/com/google/gerrit/server/restapi/change/PostReviewers.java b/java/com/google/gerrit/server/restapi/change/PostReviewers.java
index 4640e9a..cbaad81 100644
--- a/java/com/google/gerrit/server/restapi/change/PostReviewers.java
+++ b/java/com/google/gerrit/server/restapi/change/PostReviewers.java
@@ -176,7 +176,7 @@
String reviewer = input.reviewer;
ReviewerState state = input.state();
NotifyHandling notify = input.notify;
- ListMultimap<RecipientType, Account.Id> accountsToNotify = null;
+ ListMultimap<RecipientType, Account.Id> accountsToNotify;
try {
accountsToNotify = notifyUtil.resolveAccounts(input.notifyDetails);
} catch (BadRequestException e) {
@@ -233,7 +233,7 @@
boolean allowGroup,
boolean allowByEmail)
throws OrmException, PermissionBackendException, IOException, ConfigInvalidException {
- IdentifiedUser reviewerUser = null;
+ IdentifiedUser reviewerUser;
boolean exactMatchFound = false;
try {
reviewerUser = accounts.parse(reviewer);
@@ -287,7 +287,7 @@
return null;
}
- GroupDescription.Basic group = null;
+ GroupDescription.Basic group;
try {
group = groupsCollection.parseInternal(reviewer);
} catch (UnprocessableEntityException e) {
diff --git a/java/com/google/gerrit/server/restapi/project/CheckAccess.java b/java/com/google/gerrit/server/restapi/project/CheckAccess.java
index ecbb8e4..1664635 100644
--- a/java/com/google/gerrit/server/restapi/project/CheckAccess.java
+++ b/java/com/google/gerrit/server/restapi/project/CheckAccess.java
@@ -93,7 +93,7 @@
return info;
}
- RefPermission refPerm = null;
+ RefPermission refPerm;
if (!Strings.isNullOrEmpty(input.permission)) {
if (Strings.isNullOrEmpty(input.ref)) {
throw new BadRequestException("must set 'ref' when specifying 'permission'");
diff --git a/java/com/google/gerrit/server/restapi/project/DeleteRef.java b/java/com/google/gerrit/server/restapi/project/DeleteRef.java
index b7fbff4..9a9ead3 100644
--- a/java/com/google/gerrit/server/restapi/project/DeleteRef.java
+++ b/java/com/google/gerrit/server/restapi/project/DeleteRef.java
@@ -279,7 +279,7 @@
}
private void appendAndLogErrorMessage(StringBuilder errorMessages, ReceiveCommand cmd) {
- String msg = null;
+ String msg;
switch (cmd.getResult()) {
case REJECTED_CURRENT_BRANCH:
msg = format("Cannot delete %s: it is the current branch", cmd.getRefName());
diff --git a/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java b/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java
index dafc2fa..5da3c70 100644
--- a/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java
+++ b/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java
@@ -155,15 +155,18 @@
} catch (AuthException e) {
return null; // Pretend like not found on access denied.
}
- // If the project's state does not permit reading, we want to hide it from all callers. The
- // only exception to that are users who are allowed to mutate the project's configuration.
- // This enables these users to still mutate the project's state (e.g. set a HIDDEN project to
- // ACTIVE). Individual views should still check for checkStatePermitsRead() and this should
- // just serve as a safety net in case the individual check is forgotten.
- try {
- permissionBackend.currentUser().project(nameKey).check(ProjectPermission.WRITE_CONFIG);
- } catch (AuthException e) {
- state.checkStatePermitsRead();
+
+ if (!state.statePermitsRead()) {
+ // If the project's state does not permit reading, we want to hide it from all callers. The
+ // only exception to that are users who are allowed to mutate the project's configuration.
+ // This enables these users to still mutate the project's state (e.g. set a HIDDEN project
+ // to ACTIVE). Individual views should still check for checkStatePermitsRead() and this
+ // should just serve as a safety net in case the individual check is forgotten.
+ try {
+ permissionBackend.currentUser().project(nameKey).check(ProjectPermission.WRITE_CONFIG);
+ } catch (AuthException e) {
+ state.checkStatePermitsRead();
+ }
}
}
return new ProjectResource(state, user.get());
diff --git a/java/com/google/gerrit/server/submit/GitModules.java b/java/com/google/gerrit/server/submit/GitModules.java
index 1fccbdd..f616e92 100644
--- a/java/com/google/gerrit/server/submit/GitModules.java
+++ b/java/com/google/gerrit/server/submit/GitModules.java
@@ -77,14 +77,15 @@
return;
}
}
- BlobBasedConfig bbc;
+ BlobBasedConfig config;
try {
- bbc = new BlobBasedConfig(null, or.repo, commit, GIT_MODULES);
+ config = new BlobBasedConfig(null, or.repo, commit, GIT_MODULES);
} catch (ConfigInvalidException e) {
throw new IOException(
"Could not read .gitmodules of super project: " + branch.getParentKey(), e);
}
- subscriptions = new SubmoduleSectionParser(bbc, canonicalWebUrl, branch).parseAllSections();
+ subscriptions =
+ new SubmoduleSectionParser(config, canonicalWebUrl, branch).parseAllSections();
} catch (NoSuchProjectException e) {
throw new IOException(e);
}
diff --git a/java/com/google/gerrit/server/submit/MergeSuperSet.java b/java/com/google/gerrit/server/submit/MergeSuperSet.java
index 31bcc2a..2bd7d26 100644
--- a/java/com/google/gerrit/server/submit/MergeSuperSet.java
+++ b/java/com/google/gerrit/server/submit/MergeSuperSet.java
@@ -188,7 +188,7 @@
Set<String> topicsSeen = new HashSet<>();
Set<String> visibleTopicsSeen = new HashSet<>();
int oldSeen;
- int seen = 0;
+ int seen;
changeSet = topicClosure(db, changeSet, user, topicsSeen, visibleTopicsSeen);
seen = topicsSeen.size() + visibleTopicsSeen.size();
diff --git a/java/com/google/gerrit/server/submit/SubmitStrategyOp.java b/java/com/google/gerrit/server/submit/SubmitStrategyOp.java
index 51dad5b..82e3619 100644
--- a/java/com/google/gerrit/server/submit/SubmitStrategyOp.java
+++ b/java/com/google/gerrit/server/submit/SubmitStrategyOp.java
@@ -217,8 +217,6 @@
logger.atFine().log(
"%s#updateChange for change %s", getClass().getSimpleName(), toMerge.change().getId());
toMerge.setNotes(ctx.getNotes()); // Update change and notes from ctx.
- PatchSet.Id oldPsId = checkNotNull(toMerge.getPatchsetId());
- PatchSet.Id newPsId;
if (ctx.getChange().getStatus() == Change.Status.MERGED) {
// Either another thread won a race, or we are retrying a whole topic submission after one
@@ -238,10 +236,10 @@
if (alreadyMergedCommit != null) {
alreadyMergedCommit.setNotes(ctx.getNotes());
mergedPatchSet = getOrCreateAlreadyMergedPatchSet(ctx);
- newPsId = mergedPatchSet.getId();
} else {
PatchSet newPatchSet = updateChangeImpl(ctx);
- newPsId = checkNotNull(ctx.getChange().currentPatchSetId());
+ PatchSet.Id oldPsId = checkNotNull(toMerge.getPatchsetId());
+ PatchSet.Id newPsId = checkNotNull(ctx.getChange().currentPatchSetId());
if (newPatchSet == null) {
checkState(
oldPsId.equals(newPsId),
diff --git a/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java b/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java
index a92b7fd..f05d1d7 100644
--- a/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java
+++ b/java/com/google/gerrit/server/util/git/SubmoduleSectionParser.java
@@ -43,20 +43,20 @@
*/
public class SubmoduleSectionParser {
- private final Config bbc;
+ private final Config config;
private final String canonicalWebUrl;
private final Branch.NameKey superProjectBranch;
public SubmoduleSectionParser(
- Config bbc, String canonicalWebUrl, Branch.NameKey superProjectBranch) {
- this.bbc = bbc;
+ Config config, String canonicalWebUrl, Branch.NameKey superProjectBranch) {
+ this.config = config;
this.canonicalWebUrl = canonicalWebUrl;
this.superProjectBranch = superProjectBranch;
}
public Set<SubmoduleSubscription> parseAllSections() {
Set<SubmoduleSubscription> parsedSubscriptions = new HashSet<>();
- for (String id : bbc.getSubsections("submodule")) {
+ for (String id : config.getSubsections("submodule")) {
final SubmoduleSubscription subscription = parse(id);
if (subscription != null) {
parsedSubscriptions.add(subscription);
@@ -66,9 +66,9 @@
}
private SubmoduleSubscription parse(String id) {
- final String url = bbc.getString("submodule", id, "url");
- final String path = bbc.getString("submodule", id, "path");
- String branch = bbc.getString("submodule", id, "branch");
+ final String url = config.getString("submodule", id, "url");
+ final String path = config.getString("submodule", id, "path");
+ String branch = config.getString("submodule", id, "branch");
try {
if (url != null
diff --git a/java/com/google/gerrit/sshd/commands/LsUserRefs.java b/java/com/google/gerrit/sshd/commands/LsUserRefs.java
index 781679d..2c15e78 100644
--- a/java/com/google/gerrit/sshd/commands/LsUserRefs.java
+++ b/java/com/google/gerrit/sshd/commands/LsUserRefs.java
@@ -42,7 +42,7 @@
import org.eclipse.jgit.lib.Repository;
import org.kohsuke.args4j.Option;
-@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
+@RequiresCapability(GlobalCapability.READ_AS)
@CommandMetaData(
name = "ls-user-refs",
description = "List refs visible to a specific user",
diff --git a/java/com/google/gerrit/util/cli/CmdLineParser.java b/java/com/google/gerrit/util/cli/CmdLineParser.java
index 231b335..9feac3a 100644
--- a/java/com/google/gerrit/util/cli/CmdLineParser.java
+++ b/java/com/google/gerrit/util/cli/CmdLineParser.java
@@ -453,7 +453,7 @@
for (Class<?> c = bean.getClass(); c != null; c = c.getSuperclass()) {
for (Field f : c.getDeclaredFields()) {
if (f.isAnnotationPresent(Options.class)) {
- Object additionalBean = null;
+ Object additionalBean;
try {
additionalBean = f.get(bean);
} catch (IllegalAccessException e) {
diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
index 912c508..c0c8709 100644
--- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java
@@ -1977,12 +1977,10 @@
exception.expect(BadRequestException.class);
exception.expectMessage("Cannot both add and delete key: " + keyToString(key2.getPublicKey()));
- infos =
- gApi.accounts()
- .self()
- .putGpgKeys(
- ImmutableList.of(key2.getPublicKeyArmored()),
- ImmutableList.of(key2.getKeyIdString()));
+ gApi.accounts()
+ .self()
+ .putGpgKeys(
+ ImmutableList.of(key2.getPublicKeyArmored()), ImmutableList.of(key2.getKeyIdString()));
}
@Test
diff --git a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
index 18888ea..d9d730c 100644
--- a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
@@ -307,11 +307,11 @@
@Test
public void setPartialConfig() throws Exception {
ConfigInput input = createTestConfigInput();
- ConfigInfo info = gApi.projects().name(project.get()).config(input);
+ gApi.projects().name(project.get()).config(input);
ConfigInput partialInput = new ConfigInput();
partialInput.useContributorAgreements = InheritableBoolean.FALSE;
- info = gApi.projects().name(project.get()).config(partialInput);
+ ConfigInfo info = gApi.projects().name(project.get()).config(partialInput);
assertThat(info.description).isNull();
assertThat(info.useContributorAgreements.configuredValue)
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
index ca4304e..edbfe4f 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
@@ -1305,7 +1305,7 @@
oldETag = checkETag(getRevisionActions, r2, oldETag);
current(r2).submit();
- oldETag = checkETag(getRevisionActions, r2, oldETag);
+ checkETag(getRevisionActions, r2, oldETag);
}
@Test
diff --git a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
index f1e67c1..b74fc16 100644
--- a/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
+++ b/javatests/com/google/gerrit/acceptance/git/AbstractPushForReview.java
@@ -500,7 +500,7 @@
// request that sender gets notified as TO, CC and BCC, email should be sent
// even if the sender is the only recipient
sender.clear();
- r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-to=" + admin.email);
+ pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-to=" + admin.email);
assertNotifyTo(admin);
sender.clear();
@@ -1972,7 +1972,7 @@
assertThat(getPublishedComments(id1)).isEmpty();
assertThat(getPublishedComments(id2)).isEmpty();
- r2 = amendChange(id2, "refs/for/master%publish-comments");
+ amendChange(id2, "refs/for/master%publish-comments");
assertThat(getPublishedComments(id1)).isEmpty();
assertThat(gApi.changes().id(id1).drafts()).hasSize(1);
diff --git a/javatests/com/google/gerrit/acceptance/git/SubmoduleSubscriptionsIT.java b/javatests/com/google/gerrit/acceptance/git/SubmoduleSubscriptionsIT.java
index 98e3cae..03b1165 100644
--- a/javatests/com/google/gerrit/acceptance/git/SubmoduleSubscriptionsIT.java
+++ b/javatests/com/google/gerrit/acceptance/git/SubmoduleSubscriptionsIT.java
@@ -613,8 +613,9 @@
TestRepository<?> superRepo = createProjectWithPush("super-project");
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
- TestRepository<?> subRepo2 = createProjectWithPush("subscribed-to-project-2");
- subRepo2 = cloneProject(new Project.NameKey(name("subscribed-to-project-2")), user);
+ createProjectWithPush("subscribed-to-project-2");
+ TestRepository<?> subRepo2 =
+ cloneProject(new Project.NameKey(name("subscribed-to-project-2")), user);
allowMatchingSubmoduleSubscription(
"subscribed-to-project", "refs/heads/master", "super-project", "refs/heads/master");
diff --git a/javatests/com/google/gerrit/acceptance/rest/account/CapabilityInfo.java b/javatests/com/google/gerrit/acceptance/rest/account/CapabilityInfo.java
index 5404fdd..1ca019e 100644
--- a/javatests/com/google/gerrit/acceptance/rest/account/CapabilityInfo.java
+++ b/javatests/com/google/gerrit/acceptance/rest/account/CapabilityInfo.java
@@ -28,6 +28,7 @@
public boolean modifyAccount;
public boolean priority;
public QueryLimit queryLimit;
+ public boolean readAs;
public boolean runAs;
public boolean runGC;
public boolean streamEvents;
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java b/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java
index f45f9dc..0661466 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/ActionsIT.java
@@ -394,10 +394,7 @@
// ...via ChangeJson directly.
ChangeData cd = changeDataFactory.create(db, project, changeId);
- revisionInfo =
- changeJsonFactory
- .create(opts)
- .getRevisionInfo(cd, cd.patchSet(new PatchSet.Id(changeId, 1)));
+ changeJsonFactory.create(opts).getRevisionInfo(cd, cd.patchSet(new PatchSet.Id(changeId, 1)));
}
private void visitedCurrentRevisionActionsAssertions(
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/CorsIT.java b/javatests/com/google/gerrit/acceptance/rest/change/CorsIT.java
index 865c7e0a..0af9708 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/CorsIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/CorsIT.java
@@ -180,7 +180,7 @@
Executor http = Executor.newInstance().cookieStore(cookies);
Request req = Request.Get(canonicalWebUrl.get() + "/login/?account_id=" + admin.id.get());
- HttpResponse r = http.execute(req).returnResponse();
+ http.execute(req);
String auth = null;
for (Cookie c : cookies.getCookies()) {
if ("GerritAccount".equals(c.getName())) {
@@ -202,7 +202,7 @@
req.setHeader(ORIGIN, origin);
req.bodyByteArray("{\"topic\":\"test-xd\"}".getBytes(StandardCharsets.US_ASCII));
- r = http.execute(req).returnResponse();
+ HttpResponse r = http.execute(req).returnResponse();
assertThat(r.getStatusLine().getStatusCode()).isEqualTo(200);
Header vary = r.getFirstHeader(VARY);
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/SubmitByMergeIfNecessaryIT.java b/javatests/com/google/gerrit/acceptance/rest/change/SubmitByMergeIfNecessaryIT.java
index 93b3e14..b75d74f 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/SubmitByMergeIfNecessaryIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/SubmitByMergeIfNecessaryIT.java
@@ -529,7 +529,7 @@
List<String> untarredFiles = new ArrayList<>();
try (TarArchiveInputStream tarInputStream =
(TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", is)) {
- TarArchiveEntry entry = null;
+ TarArchiveEntry entry;
while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
untarredFiles.add(entry.getName());
}
diff --git a/javatests/com/google/gerrit/acceptance/server/change/PatchListCacheIT.java b/javatests/com/google/gerrit/acceptance/server/change/PatchListCacheIT.java
index ae51d1ec..580b5de 100644
--- a/javatests/com/google/gerrit/acceptance/server/change/PatchListCacheIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/change/PatchListCacheIT.java
@@ -84,7 +84,7 @@
assertDeleted(FILE_D, entries.get(2));
// Change 1,2 (+FILE_A, +FILE_B, -FILE_D)
- c = amendBuilder().add(FILE_B, "2").create();
+ amendBuilder().add(FILE_B, "2").create();
pushHead(testRepo, "refs/for/master", false);
entries = getCurrentPatches(id);
diff --git a/javatests/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java b/javatests/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java
index 424628b..29f1b7d 100644
--- a/javatests/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java
@@ -191,7 +191,7 @@
public void patchSets() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getPatchSetId().getParentKey();
- r = amendChange(r.getChangeId());
+ amendChange(r.getChangeId());
checker.rebuildAndCheckChanges(id);
}
diff --git a/javatests/com/google/gerrit/acceptance/ssh/UploadArchiveIT.java b/javatests/com/google/gerrit/acceptance/ssh/UploadArchiveIT.java
index 1721545..93fc769 100644
--- a/javatests/com/google/gerrit/acceptance/ssh/UploadArchiveIT.java
+++ b/javatests/com/google/gerrit/acceptance/ssh/UploadArchiveIT.java
@@ -75,7 +75,7 @@
PacketLineIn in = new PacketLineIn(out);
String tmp = in.readString();
assertThat(tmp).isEqualTo("ACK");
- tmp = in.readString();
+ in.readString();
// Skip length (4 bytes) + 1 byte
// to position the output stream to the raw zip stream
@@ -150,7 +150,7 @@
PacketLineIn in = new PacketLineIn(out);
String tmp = in.readString();
assertThat(tmp).isEqualTo("ACK");
- tmp = in.readString();
+ in.readString();
tmp = in.readString();
tmp = tmp.substring(1);
assertThat(tmp).isEqualTo("fatal: upload-archive not permitted for format zip");
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
index 8b3c08f..f67f990 100644
--- a/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
+++ b/javatests/com/google/gerrit/elasticsearch/ElasticContainer.java
@@ -45,13 +45,13 @@
case V2_4:
return "elasticsearch:2.4.6-alpine";
case V5_6:
- return "docker.elastic.co/elasticsearch/elasticsearch:5.6.11";
+ return "docker.elastic.co/elasticsearch/elasticsearch:5.6.12";
case V6_2:
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4";
case V6_3:
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.3.2";
case V6_4:
- return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.0";
+ return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.1";
}
throw new IllegalStateException("No tests for version: " + version.name());
}
diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
index 2e6e48a..549f5db 100644
--- a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
+++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
@@ -721,8 +721,6 @@
update.setAssignee(otherUserId);
update.commit();
- ChangeNotes notes = newNotes(c);
-
update = newUpdate(c, changeOwner);
update.setAssignee(changeOwner.getAccountId());
update.commit();
@@ -735,7 +733,7 @@
update.removeAssignee();
update.commit();
- notes = newNotes(c);
+ ChangeNotes notes = newNotes(c);
assertThat(notes.getPastAssignees()).hasSize(2);
}
diff --git a/javatests/com/google/gerrit/server/permissions/RefControlTest.java b/javatests/com/google/gerrit/server/permissions/RefControlTest.java
index 39896ed..31eee9f 100644
--- a/javatests/com/google/gerrit/server/permissions/RefControlTest.java
+++ b/javatests/com/google/gerrit/server/permissions/RefControlTest.java
@@ -47,7 +47,6 @@
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
-import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.CapabilityCollection;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.account.ListGroupMembership;
@@ -204,7 +203,6 @@
@Inject private InMemoryDatabase schemaFactory;
@Inject private ThreadLocalRequestContext requestContext;
@Inject private DefaultRefFilter.Factory refFilterFactory;
- @Inject private IdentifiedUser.GenericFactory identifiedUserFactory;
@Inject private TransferConfig transferConfig;
@Before
@@ -991,7 +989,6 @@
changeControlFactory,
permissionBackend,
refFilterFactory,
- identifiedUserFactory,
new MockUser(name, memberOf),
newProjectState(local));
}
diff --git a/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
index aae1f1b..41f60bb 100644
--- a/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
+++ b/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
@@ -73,6 +73,7 @@
import com.google.gerrit.index.Schema;
import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.reviewdb.client.Account;
+import com.google.gerrit.reviewdb.client.Account.Id;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch;
@@ -198,6 +199,9 @@
// These queries must be kept in sync with PolyGerrit:
// polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
+ protected static final String DASHBOARD_HAS_UNPUBLISHED_DRAFTS_QUERY = "has:draft";
+ protected static final String DASHBOARD_ASSIGNED_QUERY =
+ "assignee:${user} (-is:wip OR " + "owner:self OR assignee:self)";
protected static final String DASHBOARD_WORK_IN_PROGRESS_QUERY = "is:open owner:${user} is:wip";
protected static final String DASHBOARD_OUTGOING_QUERY =
"is:open owner:${user} -is:wip -is:ignored";
@@ -205,7 +209,8 @@
"is:open -owner:${user} -is:wip -is:ignored (reviewer:${user} OR assignee:${user})";
protected static final String DASHBOARD_RECENTLY_CLOSED_QUERY =
"is:closed -is:ignored (-is:wip OR owner:self) "
- + "(owner:${user} OR reviewer:${user} OR assignee:${user})";
+ + "(owner:${user} OR reviewer:${user} OR assignee:${user} "
+ + "OR cc:${user})";
protected abstract Injector createInjector();
@@ -1955,7 +1960,7 @@
actual = assertQuery(newQuery("-is:reviewed").withOption(REVIEWED), change1);
assertThat(actual.get(0).reviewed).isNull();
- actual = assertQuery("reviewedby:" + userId.get());
+ assertQuery("reviewedby:" + userId.get());
actual =
assertQuery(newQuery("reviewedby:" + user2.get()).withOption(REVIEWED), change3, change2);
@@ -2585,7 +2590,10 @@
protected class DashboardChangeState {
private final Account.Id ownerId;
private final List<Account.Id> reviewedBy;
+ private final List<Account.Id> cced;
private final List<Account.Id> ignoredBy;
+ private final List<Account.Id> draftCommentBy;
+ private final List<Account.Id> deleteDraftCommentBy;
private boolean wip;
private boolean abandoned;
@Nullable private Account.Id mergedBy;
@@ -2596,7 +2604,10 @@
DashboardChangeState(Account.Id ownerId) {
this.ownerId = ownerId;
reviewedBy = new ArrayList<>();
+ cced = new ArrayList<>();
ignoredBy = new ArrayList<>();
+ draftCommentBy = new ArrayList<>();
+ deleteDraftCommentBy = new ArrayList<>();
}
DashboardChangeState assignTo(Account.Id assigneeId) {
@@ -2629,6 +2640,21 @@
return this;
}
+ DashboardChangeState addCc(Account.Id ccId) {
+ cced.add(ccId);
+ return this;
+ }
+
+ DashboardChangeState draftCommentBy(Account.Id commenterId) {
+ draftCommentBy.add(commenterId);
+ return this;
+ }
+
+ DashboardChangeState draftAndDeleteCommentBy(Id commenterId) {
+ deleteDraftCommentBy.add(commenterId);
+ return this;
+ }
+
DashboardChangeState create(TestRepository<Repo> repo) throws Exception {
requestContext.setContext(newRequestContext(ownerId));
Change change = insert(repo, newChange(repo), ownerId);
@@ -2648,11 +2674,28 @@
for (Account.Id reviewerId : reviewedBy) {
cApi.addReviewer("" + reviewerId);
}
+ for (Account.Id reviewerId : cced) {
+ AddReviewerInput in = new AddReviewerInput();
+ in.reviewer = reviewerId.toString();
+ in.state = ReviewerState.CC;
+ cApi.addReviewer(in);
+ }
for (Account.Id ignorerId : ignoredBy) {
requestContext.setContext(newRequestContext(ignorerId));
StarsInput in = new StarsInput(new HashSet<>(Arrays.asList("ignore")));
gApi.accounts().self().setStars("" + id, in);
}
+ DraftInput in = new DraftInput();
+ in.path = Patch.COMMIT_MSG;
+ in.message = "message";
+ for (Account.Id commenterId : draftCommentBy) {
+ requestContext.setContext(newRequestContext(commenterId));
+ gApi.changes().id(change.getChangeId()).current().createDraft(in);
+ }
+ for (Account.Id commenterId : deleteDraftCommentBy) {
+ requestContext.setContext(newRequestContext(commenterId));
+ gApi.changes().id(change.getChangeId()).current().createDraft(in).delete();
+ }
if (mergedBy != null) {
requestContext.setContext(newRequestContext(mergedBy));
cApi = gApi.changes().id(change.getChangeId());
@@ -2674,6 +2717,43 @@
}
@Test
+ public void dashboardHasUnpublishedDrafts() throws Exception {
+ TestRepository<Repo> repo = createProject("repo");
+ Account.Id otherAccountId = createAccount("other");
+ DashboardChangeState hasUnpublishedDraft =
+ new DashboardChangeState(otherAccountId).draftCommentBy(user.getAccountId()).create(repo);
+
+ // Create changes that should not be returned by query.
+ new DashboardChangeState(user.getAccountId()).create(repo);
+ new DashboardChangeState(user.getAccountId()).draftCommentBy(otherAccountId).create(repo);
+ new DashboardChangeState(user.getAccountId())
+ .draftAndDeleteCommentBy(user.getAccountId())
+ .create(repo);
+
+ assertDashboardQuery("self", DASHBOARD_HAS_UNPUBLISHED_DRAFTS_QUERY, hasUnpublishedDraft);
+ }
+
+ @Test
+ public void dashboardAssignedReviews() throws Exception {
+ TestRepository<Repo> repo = createProject("repo");
+ Account.Id otherAccountId = createAccount("other");
+ DashboardChangeState otherOpenWip =
+ new DashboardChangeState(otherAccountId).wip().assignTo(user.getAccountId()).create(repo);
+ DashboardChangeState selfOpenWip =
+ new DashboardChangeState(user.getAccountId())
+ .wip()
+ .assignTo(user.getAccountId())
+ .create(repo);
+
+ // Create changes that should not be returned by query.
+ assertDashboardQuery("self", DASHBOARD_ASSIGNED_QUERY, selfOpenWip, otherOpenWip);
+
+ // Viewing another user's dashboard.
+ requestContext.setContext(newRequestContext(otherAccountId));
+ assertDashboardQuery(user.getUserName().get(), DASHBOARD_ASSIGNED_QUERY, otherOpenWip);
+ }
+
+ @Test
public void dashboardWorkInProgressReviews() throws Exception {
TestRepository<Repo> repo = createProject("repo");
DashboardChangeState ownedOpenWip =
@@ -2773,6 +2853,11 @@
.ignoreBy(user.getAccountId())
.mergeBy(user.getAccountId())
.create(repo);
+ DashboardChangeState mergedCced =
+ new DashboardChangeState(otherAccountId)
+ .addCc(user.getAccountId())
+ .mergeBy(user.getAccountId())
+ .create(repo);
DashboardChangeState mergedAssigned =
new DashboardChangeState(otherAccountId)
.assignTo(user.getAccountId())
@@ -2859,6 +2944,7 @@
abandonedOwnedIgnoredByOther,
abandonedOwned,
mergedAssigned,
+ mergedCced,
mergedReviewing,
mergedOwnedIgnoredByOther,
mergedOwned);
@@ -2877,6 +2963,7 @@
abandonedOwned,
mergedAssignedIgnoredByUser,
mergedAssigned,
+ mergedCced,
mergedReviewingIgnoredByUser,
mergedReviewing,
mergedOwned);
diff --git a/javatests/com/google/gerrit/server/query/project/AbstractQueryProjectsTest.java b/javatests/com/google/gerrit/server/query/project/AbstractQueryProjectsTest.java
index 8790c64..420c323 100644
--- a/javatests/com/google/gerrit/server/query/project/AbstractQueryProjectsTest.java
+++ b/javatests/com/google/gerrit/server/query/project/AbstractQueryProjectsTest.java
@@ -269,7 +269,7 @@
"name:" + project1.name + " OR name:" + project2.name + " OR name:" + project3.name;
List<ProjectInfo> result = assertQuery(query, project1, project2, project3);
- result = assertQuery(newQuery(query).withLimit(2), result.subList(0, 2));
+ assertQuery(newQuery(query).withLimit(2), result.subList(0, 2));
}
@Test
diff --git a/lib/jgit/jgit.bzl b/lib/jgit/jgit.bzl
index 7191901..816c3a3 100644
--- a/lib/jgit/jgit.bzl
+++ b/lib/jgit/jgit.bzl
@@ -1,6 +1,6 @@
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_CENTRAL", "MAVEN_LOCAL", "maven_jar")
-_JGIT_VERS = "5.0.3.201809091024-r"
+_JGIT_VERS = "5.1.1.201809181055-r"
_DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot
@@ -40,28 +40,28 @@
name = "jgit-lib",
artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
repository = _JGIT_REPO,
- sha1 = "0afec2df3ff8835bc4d5c279d14fad0daae6dd93",
- src_sha1 = "e2c978064e2a46b260bbda0d8c393ed741046420",
+ sha1 = "64dfe41b3c152bb9b7158b214e28467cb1217153",
+ src_sha1 = "ff6ab018897cf4213b905e156ac5930bad2bdff1",
unsign = True,
)
maven_jar(
name = "jgit-servlet",
artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
repository = _JGIT_REPO,
- sha1 = "8fb0f9b6c38ac6fce60f2ead740e03dd79c3c288",
+ sha1 = "22fd6827fbb6135efd813271185a91f8615538eb",
unsign = True,
)
maven_jar(
name = "jgit-archive",
artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
repository = _JGIT_REPO,
- sha1 = "72a157ce261f3eb938d9e0ee83d7c9700aa7d736",
+ sha1 = "bfbbdd6aa1893db14f346913aad3f9898b2fe01d",
)
maven_jar(
name = "jgit-junit",
artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
repository = _JGIT_REPO,
- sha1 = "eb430358d96dedd923e4075cd54a7db4cab51ca2",
+ sha1 = "6de6de74053d7c28100fe128255d7382a939fe99",
unsign = True,
)
diff --git a/plugins/reviewnotes b/plugins/reviewnotes
index 920f28b..54525ff 160000
--- a/plugins/reviewnotes
+++ b/plugins/reviewnotes
@@ -1 +1 @@
-Subproject commit 920f28b46021d9c49fac09d869aa4040d13796e7
+Subproject commit 54525ffaed5e8925d97657a622532a00a0006347
diff --git a/polygerrit-ui/BUILD b/polygerrit-ui/BUILD
index fddfc57..384f835 100644
--- a/polygerrit-ui/BUILD
+++ b/polygerrit-ui/BUILD
@@ -2,6 +2,7 @@
default_visibility = ["//visibility:public"],
)
+load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("//tools/bzl:js.bzl", "bower_component_bundle")
load("//tools/bzl:genrule2.bzl", "genrule2")
@@ -52,3 +53,19 @@
output_to_bindir = 1,
visibility = ["//visibility:public"],
)
+
+go_binary(
+ name = "devserver",
+ srcs = ["server.go"],
+ data = [
+ ":fonts.zip",
+ "//polygerrit-ui/app:test_components.zip",
+ "//resources/com/google/gerrit/httpd/raw",
+ ],
+ deps = [
+ "@com_github_robfig_soy//:go_default_library",
+ "@com_github_robfig_soy//soyhtml:go_default_library",
+ "@org_golang_x_tools//godoc/vfs/httpfs:go_default_library",
+ "@org_golang_x_tools//godoc/vfs/zipfs:go_default_library",
+ ],
+)
diff --git a/polygerrit-ui/README.md b/polygerrit-ui/README.md
index c119562..3c21a42 100644
--- a/polygerrit-ui/README.md
+++ b/polygerrit-ui/README.md
@@ -48,32 +48,6 @@
Unfortunately, you can't sign in, so testing certain features will require
you to use the "test data" technique described below.
-### Installing [go](https://golang.org/)
-
-This is required for running the `run-server.sh` script below.
-
-```sh
-# Debian/Ubuntu
-sudo apt-get install golang
-
-# OS X with Homebrew
-brew install go
-```
-
-All other platforms: [download from golang.org](https://golang.org/)
-
-Then add go to your path:
-
-```
-PATH=$PATH:/usr/local/go/bin
-```
-
-Install the go Soy template library:
-
-```
-go get "github.com/robfig/soy"
-```
-
### Running the server
To test the local UI against gerrit-review.googlesource.com:
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
index d84dec5..72ef0e5 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.js
@@ -22,15 +22,22 @@
// NOTE: These queries are tested in Java. Any changes made to definitions
// here require corresponding changes to:
- // gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
+ // javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
const DEFAULT_SECTIONS = [
{
// Changes with unpublished draft comments. This section is omitted when
// viewing other users, so we don't need to filter anything out.
- name: 'Has unpublished drafts',
+ name: 'Has draft comments',
query: 'has:draft',
selfOnly: true,
hideIfEmpty: true,
+ suffixForDashboard: 'limit:10',
+ },
+ {
+ // Changes that are assigned to the viewed user.
+ name: 'Assigned reviews',
+ query: 'assignee:${user} (-is:wip OR owner:self OR assignee:self)',
+ hideIfEmpty: true,
},
{
// WIP open changes owned by viewing user. This section is omitted when
diff --git a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
index 5a4aaac..89b3548 100644
--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
@@ -53,6 +53,7 @@
content: "";
display: inline-block;
height: var(--header-icon-size);
+ margin-right: calc(var(--header-icon-size) / 4);
vertical-align: text-bottom;
width: var(--header-icon-size);
}
diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
index 6c7903d..db14fc8 100644
--- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
+++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-layer/gr-ranged-comment-layer.js
@@ -72,7 +72,7 @@
/**
* Register a listener for layer updates.
- * @param {Function<Number, Number, String>} fn The update handler function.
+ * @param {function(number, number, string)} fn The update handler function.
* Should accept as arguments the line numbers for the start and end of
* the update and the side as a string.
*/
diff --git a/polygerrit-ui/app/elements/gr-app.html b/polygerrit-ui/app/elements/gr-app.html
index e7bd965..787a1c6 100644
--- a/polygerrit-ui/app/elements/gr-app.html
+++ b/polygerrit-ui/app/elements/gr-app.html
@@ -26,6 +26,10 @@
passiveTouchGestures: true,
};
}
+ // Needed for JSCompiler to understand it's global.
+ // eslint-disable-next-line no-unused-vars, prefer-const
+ let Gerrit = window.Gerrit || {};
+ window.Gerrit = Gerrit;
</script>
<link rel="import" href="../bower_components/polymer/polymer.html">
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.js
index cb8409e..47281c2 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-annotation-actions-js-api.js
@@ -34,7 +34,7 @@
* Register a function to call to apply annotations. Plugins should use
* GrAnnotationActionsContext.annotateRange to apply a CSS class to a range
* within a line.
- * @param {Function<GrAnnotationActionsContext>} addLayerFunc The function
+ * @param {function(GrAnnotationActionsContext)} addLayerFunc The function
* that will be called when the AnnotationLayer is ready to annotate.
*/
GrAnnotationActionsInterface.prototype.addLayer = function(addLayerFunc) {
@@ -45,7 +45,7 @@
/**
* The specified function will be called with a notify function for the plugin
* to call when it has all required data for annotation. Optional.
- * @param {Function<Function<String, Number, Number, String>>} notifyFunc See
+ * @param {function(function(String, Number, Number, String))} notifyFunc See
* doc of the notify function below to see what it does.
*/
GrAnnotationActionsInterface.prototype.addNotifier = function(notifyFunc) {
@@ -68,7 +68,7 @@
*
* @param {String} checkboxLabel Will be used as the label for the checkbox.
* Optional. "Enable" is used if this is not specified.
- * @param {Function<HTMLElement>} onAttached The function that will be called
+ * @param {function(HTMLElement)} onAttached The function that will be called
* when the checkbox is attached to the page.
*/
GrAnnotationActionsInterface.prototype.enableToggleCheckbox = function(
@@ -134,7 +134,7 @@
* @param {String} path The file path (eg: /COMMIT_MSG').
* @param {String} changeNum The Gerrit change number.
* @param {String} patchNum The Gerrit patch number.
- * @param {Function<GrAnnotationActionsContext>} addLayerFunc The function
+ * @param {function(GrAnnotationActionsContext)} addLayerFunc The function
* that will be called when the AnnotationLayer is ready to annotate.
*/
function AnnotationLayer(path, changeNum, patchNum, addLayerFunc) {
@@ -148,7 +148,7 @@
/**
* Register a listener for layer updates.
- * @param {Function<Number, Number, String>} fn The update handler function.
+ * @param {function(Number, Number, String)} fn The update handler function.
* Should accept as arguments the line numbers for the start and end of
* the update and the side as a string.
*/
diff --git a/polygerrit-ui/app/embed/embed.html b/polygerrit-ui/app/embed/embed.html
index 9fb5c23..be4e2f3 100644
--- a/polygerrit-ui/app/embed/embed.html
+++ b/polygerrit-ui/app/embed/embed.html
@@ -14,6 +14,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+<script>
+ // Needed for JSCompiler to understand it's global.
+ // eslint-disable-next-line no-unused-vars, prefer-const
+ let Gerrit = window.Gerrit || {};
+ window.Gerrit = Gerrit;
+</script>
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../elements/change/gr-change-view/gr-change-view.html">
<link rel="import" href="../elements/core/gr-search-bar/gr-search-bar.html">
diff --git a/polygerrit-ui/app/gr-diff/gr-diff-root.html b/polygerrit-ui/app/gr-diff/gr-diff-root.html
new file mode 100644
index 0000000..132654c
--- /dev/null
+++ b/polygerrit-ui/app/gr-diff/gr-diff-root.html
@@ -0,0 +1,7 @@
+<script>
+ // Needed for JSCompiler to understand it's global.
+ // eslint-disable-next-line no-unused-vars, prefer-const
+ let Gerrit = window.Gerrit || {};
+ window.Gerrit = Gerrit;
+</script>
+<link rel="import" href="../elements/diff/gr-diff/gr-diff.html">
diff --git a/polygerrit-ui/run-server.sh b/polygerrit-ui/run-server.sh
index cbe3563..64bca68 100755
--- a/polygerrit-ui/run-server.sh
+++ b/polygerrit-ui/run-server.sh
@@ -14,23 +14,7 @@
# limitations under the License.
set -eu
-
-while [[ ! -f WORKSPACE && "$PWD" != / ]]; do
- cd ..
-done
-if [[ ! -f WORKSPACE ]]; then
- echo "$(basename "$0"): must be run from a gerrit checkout" 1>&2
- exit 1
-fi
-
-bazel build \
- //polygerrit-ui/app:test_components \
- //polygerrit-ui:fonts.zip
-
-cd polygerrit-ui/app
-rm -rf bower_components
-unzip -q ../../bazel-bin/polygerrit-ui/app/test_components.zip
-rm -rf fonts
-unzip -q ../../bazel-bin/polygerrit-ui/fonts.zip -d fonts
-cd ..
-exec go run server.go "$@"
+SCRIPTNAME=$(mktemp)
+trap "{ rm -f $SCRIPTNAME; }" EXIT
+bazel run --script_path="$SCRIPTNAME" //polygerrit-ui:devserver
+"$SCRIPTNAME" "$@"
diff --git a/polygerrit-ui/server.go b/polygerrit-ui/server.go
index f44f4d7..ba685184 100644
--- a/polygerrit-ui/server.go
+++ b/polygerrit-ui/server.go
@@ -15,6 +15,7 @@
package main
import (
+ "archive/zip"
"bufio"
"compress/gzip"
"encoding/json"
@@ -26,27 +27,50 @@
"net"
"net/http"
"net/url"
+ "os"
+ "path/filepath"
"regexp"
"strings"
"github.com/robfig/soy"
+ "github.com/robfig/soy/soyhtml"
+ "golang.org/x/tools/godoc/vfs/httpfs"
+ "golang.org/x/tools/godoc/vfs/zipfs"
)
var (
- restHost = flag.String("host", "gerrit-review.googlesource.com", "Host to proxy requests to")
+ plugins = flag.String("plugins", "", "comma seperated plugin paths to serve")
port = flag.String("port", ":8081", "Port to serve HTTP requests on")
prod = flag.Bool("prod", false, "Serve production assets")
+ restHost = flag.String("host", "gerrit-review.googlesource.com", "Host to proxy requests to")
scheme = flag.String("scheme", "https", "URL scheme")
- plugins = flag.String("plugins", "", "comma seperated plugin paths to serve")
- tofu, _ = soy.NewBundle().
- AddTemplateFile("../resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy").
- CompileToTofu()
+ tofu *soyhtml.Tofu
)
func main() {
flag.Parse()
+ fontsArchive, err := openDataArchive("fonts.zip")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ componentsArchive, err := openDataArchive("app/test_components.zip")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ tofu, err = resolveIndexTemplate()
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ workspace := os.Getenv("BUILD_WORKSPACE_DIRECTORY")
+ if err := os.Chdir(filepath.Join(workspace, "polygerrit-ui")); err != nil {
+ log.Fatal(err)
+ }
+
http.HandleFunc("/index.html", handleIndex)
if *prod {
@@ -55,6 +79,11 @@
http.Handle("/", http.FileServer(http.Dir("app")))
}
+ http.Handle("/bower_components/",
+ http.FileServer(httpfs.New(zipfs.New(componentsArchive, "bower_components"))))
+ http.Handle("/fonts/",
+ http.FileServer(httpfs.New(zipfs.New(fontsArchive, "fonts"))))
+
http.HandleFunc("/changes/", handleRESTProxy)
http.HandleFunc("/accounts/", handleRESTProxy)
http.HandleFunc("/config/", handleRESTProxy)
@@ -71,6 +100,28 @@
log.Fatal(http.ListenAndServe(*port, &server{}))
}
+func resolveIndexTemplate() (*soyhtml.Tofu, error) {
+ basePath, err := resourceBasePath()
+ if err != nil {
+ return nil, err
+ }
+ return soy.NewBundle().
+ AddTemplateFile(basePath + ".runfiles/gerrit/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy").
+ CompileToTofu()
+}
+
+func openDataArchive(path string) (*zip.ReadCloser, error) {
+ absBinPath, err := resourceBasePath()
+ if err != nil {
+ return nil, err
+ }
+ return zip.OpenReader(absBinPath + ".runfiles/gerrit/polygerrit-ui/" + path)
+}
+
+func resourceBasePath() (string, error) {
+ return filepath.Abs(os.Args[0])
+}
+
func handleIndex(w http.ResponseWriter, r *http.Request) {
var obj = map[string]interface{}{
"canonicalPath": "",
diff --git a/resources/com/google/gerrit/httpd/raw/BUILD b/resources/com/google/gerrit/httpd/raw/BUILD
new file mode 100644
index 0000000..3cd3ce8
--- /dev/null
+++ b/resources/com/google/gerrit/httpd/raw/BUILD
@@ -0,0 +1,8 @@
+filegroup(
+ name = "raw",
+ srcs = glob(
+ ["**/*"],
+ exclude = ["BUILD"],
+ ),
+ visibility = ["//visibility:public"],
+)
diff --git a/resources/com/google/gerrit/server/config/CapabilityConstants.properties b/resources/com/google/gerrit/server/config/CapabilityConstants.properties
index 6654837..ba590ee 100644
--- a/resources/com/google/gerrit/server/config/CapabilityConstants.properties
+++ b/resources/com/google/gerrit/server/config/CapabilityConstants.properties
@@ -10,6 +10,7 @@
maintainServer = Maintain Server
modifyAccount = Modify Account
priority = Priority
+readAs = Read As
queryLimit = Query Limit
runAs = Run As
runGC = Run Garbage Collection
diff --git a/tools/BUILD b/tools/BUILD
index 73ecfb9..c368eed 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -1,4 +1,8 @@
-load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
+load(
+ "@bazel_tools//tools/jdk:default_java_toolchain.bzl",
+ "JDK9_JVM_OPTS",
+ "default_java_toolchain",
+)
py_binary(
name = "merge_jars",
@@ -7,44 +11,10 @@
visibility = ["//visibility:public"],
)
-# TODO(davido): remove this when minimum suported Bazel version >= 0.17
-# Copied from tools/jdk/default_java_toolchain.bzl to make Bazel 0.16
-# and later Bazel released to work as expected. See this issue for context:
-# https://github.com/bazelbuild/bazel/issues/6009
-JDK9_JVM_OPTS = [
- # Allow JavaBuilder to access internal javac APIs.
- "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
- "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
- "--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
- "--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
- "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
- "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
- "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
- "--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-
- # override the javac in the JDK.
- "--patch-module=java.compiler=$(location @bazel_tools//third_party/java/jdk/langtools:java_compiler_jar)",
- "--patch-module=jdk.compiler=$(location @bazel_tools//third_party/java/jdk/langtools:jdk_compiler_jar)",
-
- # quiet warnings from com.google.protobuf.UnsafeUtil,
- # see: https://github.com/google/protobuf/issues/3781
- "--add-opens=java.base/java.nio=ALL-UNNAMED",
-]
-
-# See https://github.com/bazelbuild/bazel/issues/3427 for more context
-default_java_toolchain(
- name = "error_prone_warnings_toolchain_bazel_0.16",
- bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
- jvm_opts = JDK9_JVM_OPTS,
- package_configuration = [
- ":error_prone",
- ],
- visibility = ["//visibility:public"],
-)
-
default_java_toolchain(
name = "error_prone_warnings_toolchain",
- bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
+ bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath9.jar"],
+ jvm_opts = JDK9_JVM_OPTS,
package_configuration = [
":error_prone",
],