Merge branch 'stable-2.15' into stable-2.16 * stable-2.15: Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Change-Id: I21b9bfcb3a2e34b265820efe7dea884d0c0aa2bf
diff --git a/.bazelversion b/.bazelversion index 9084fa2..227cea2 100644 --- a/.bazelversion +++ b/.bazelversion
@@ -1 +1 @@ -1.1.0 +2.0.0
diff --git a/BUILD b/BUILD index 93bb716..4de410f 100644 --- a/BUILD +++ b/BUILD
@@ -6,6 +6,8 @@ "gerrit_plugin", ) load("//tools/bzl:junit.bzl", "junit_tests") +load("//tools/bzl:genrule2.bzl", "genrule2") +load("//tools/bzl:js.bzl", "polygerrit_plugin") gerrit_plugin( name = "verify-status", @@ -20,6 +22,7 @@ "Implementation-Title: Verify Status Plugin", "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/verify-status", ], + resource_jars = [":gr-verify-status-static"], resources = glob(["src/main/**/*"]), ) @@ -41,3 +44,24 @@ ":verify-status__plugin", ], ) + +genrule2( + name = "gr-verify-status-static", + srcs = [":gr-verify-status"], + outs = ["gr-verify-status-static.jar"], + cmd = " && ".join([ + "mkdir $$TMP/static", + "cp -r $(locations :gr-verify-status) $$TMP/static", + "cd $$TMP", + "zip -Drq $$ROOT/$@ -g .", + ]), +) + +polygerrit_plugin( + name = "gr-verify-status", + srcs = [ + "gr-verify-status/gr-verify-status-panel.html", + "gr-verify-status/gr-verify-status-panel.js", + ], + app = "plugin.html", +)
diff --git a/WORKSPACE b/WORKSPACE index 0a8cf9e..01bc31a 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -3,10 +3,34 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "f53f51fb660552d0581aa0ba52c3836ed63d56a3", + commit = "59529f046a5cb855d9fe3ee87110d53305ec69b9", #local_path = "/home/<user>/projects/bazlets", ) +# Polymer dependencies +load( + "@com_googlesource_gerrit_bazlets//:gerrit_polymer.bzl", + "gerrit_polymer", +) + +gerrit_polymer() + +# Load closure compiler with transitive dependencies +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") + +closure_repositories() + +# Load Gerrit npm_binary toolchain +load("@com_googlesource_gerrit_bazlets//tools:js.bzl", "GERRIT", "npm_binary") +npm_binary( + name = "polymer-bundler", + repository = GERRIT, +) +npm_binary( + name = "crisper", + repository = GERRIT, +) + # Snapshot Plugin API #load( # "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
diff --git a/gr-verify-status/gr-verify-status-panel.html b/gr-verify-status/gr-verify-status-panel.html new file mode 100644 index 0000000..e34af9c --- /dev/null +++ b/gr-verify-status/gr-verify-status-panel.html
@@ -0,0 +1,45 @@ +<!-- +Copyright (C) 2019 The Android Open Source Project +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> + +<dom-module id="gr-verify-status-panel"> + <template> + <style include="gr-form-styles"></style> + <style> + .u-green { + color: #388E3C; + } + .u-red { + color: #D32F2F; + } + </style> + <div id="gr-verify-status"> + <span class="u-green">Passed: [[verifyStatus.summary.passed]]</span>, + <span class="u-red">Failed: [[verifyStatus.summary.failed]]</span>, + <span class="u-black">Not done: [[verifyStatus.summary.notdone]]</span> + </div> + <div class="separatedSection style-scope gr-change-metadata" + style="margin-top: 0; padding: 0"> + <table class="test_result_table"> + <tbody> + <template is="dom-repeat" items="{{verifyStatus.results}}"> + <tr> + <td class="cell verifiedstatus"><a href$="[[item.url]]">[[item.name]]</a></td> + <td class="cell verifiedstatus verifiedstatus_value">[[item.value]]</td> + </tr> + </template> + </tbody> + </table> + </div> + </template> + <script src="gr-verify-status-panel.js"></script> +</dom-module>
diff --git a/gr-verify-status/gr-verify-status-panel.js b/gr-verify-status/gr-verify-status-panel.js new file mode 100644 index 0000000..bdacdef --- /dev/null +++ b/gr-verify-status/gr-verify-status-panel.js
@@ -0,0 +1,75 @@ +// Copyright (C) 2019 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +(function() { + 'use strict'; + const Defs = {}; + /** + * @typedef {{ + * summary: Object, + * results: Array, + * }} + */ + Defs.verifyStatus; + + Polymer({ + is: 'gr-verify-status-panel', + + properties: { + verifyStatus: { + /** @type {Defs.verifystatus} */ + type: Object, + }, + revision: { + type: Object, + }, + change: { + type: Object, + } + }, + + attached() { + this._fetchData(this.revision); + }, + + _fetchData(revision) { + if (!revision) return; + const query ='/verify-status~verifications?sort=REPORTER&filter=CURRENT'; + const endpoint = '/changes/' + this.change.id + '/revisions/' + + revision._number + query; + + const errFn = response => { + this.fire('page-error', {response}); + }; + + this.plugin.restApi().get(endpoint, errFn).then(r => { + let summary = {failed:0, passed:0, notdone:0}; + let results = []; + for (let checkid in r) { + let check= r[checkid]; + if (check.value == '0') { + summary.notdone +=1;} + else if (check.value == 1) { + summary.passed +=1; + } + else { + summary.failed +=1; + } + results.push(check); + }; + + this.verifyStatus = {summary, results}; + }); + }, + }); +}());
diff --git a/plugin.html b/plugin.html new file mode 100644 index 0000000..e1b3d61 --- /dev/null +++ b/plugin.html
@@ -0,0 +1,28 @@ +<!-- +Copyright (C) 2019 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> + +<link rel="import" href="./gr-verify-status/gr-verify-status-panel.html"> + +<dom-module id="verify-status"> + <script> + if (window.Polymer) { + Gerrit.install(function(plugin) { + plugin.registerCustomComponent( + 'change-metadata-item', 'gr-verify-status-panel'); + }); + } + </script> +</dom-module>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java index d0959e0..cf557ba 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
@@ -16,6 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; +import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; import com.google.inject.servlet.ServletModule; @@ -23,5 +24,7 @@ @Override protected void configureServlets() { DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("verifystatus")); + DynamicSet.bind(binder(), WebUiPlugin.class) + .toInstance(new JavaScriptPlugin("gr-verify-status.html")); } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java index a937b09..18d2da7 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java +++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
@@ -17,13 +17,13 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.gerrit.common.TimeUtil; import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.reviewdb.client.LabelId; import com.google.gerrit.server.change.RevisionResource; +import com.google.gerrit.server.util.time.TimeUtil; import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.SchemaFactory; import com.google.inject.Inject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java index 97d7114..1254421 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
@@ -23,11 +23,11 @@ import com.google.gerrit.extensions.restapi.IdString; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.reviewdb.client.PatchSet; -import com.google.gerrit.server.change.ChangesCollection; import com.google.gerrit.server.change.RevisionResource; -import com.google.gerrit.server.change.Revisions; import com.google.gerrit.server.permissions.PermissionBackendException; -import com.google.gerrit.server.project.ProjectControl; +import com.google.gerrit.server.project.ProjectState; +import com.google.gerrit.server.restapi.change.ChangesCollection; +import com.google.gerrit.server.restapi.change.Revisions; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; import com.google.gerrit.sshd.commands.PatchSetParser; @@ -59,7 +59,7 @@ usage = "list of commits or patch sets to verify") void addPatchSetId(String token) { try { - PatchSet ps = psParser.parsePatchSet(token, projectControl, branch); + PatchSet ps = psParser.parsePatchSet(token, projectState, branch); patchSets.add(ps); } catch (UnloggedFailure e) { throw new IllegalArgumentException(e.getMessage(), e); @@ -72,7 +72,7 @@ name = "--project", aliases = "-p", usage = "project containing the specified patch set(s)") - private ProjectControl projectControl; + private ProjectState projectState; @Option(name = "--branch", aliases = "-b", usage = "branch containing the specified patch set(s)") private String branch;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java index 3765d33..5edb3eb 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java +++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java
@@ -16,9 +16,9 @@ import static java.nio.charset.StandardCharsets.UTF_8; -import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.Version; import com.google.gerrit.extensions.annotations.RequiresCapability; +import com.google.gerrit.server.util.time.TimeUtil; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gwtorm.jdbc.JdbcSchema;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java index 2906561..61a689b 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
@@ -69,8 +69,8 @@ @Before @Override - public void setUp() throws Exception { - super.setUp(); + public void setUpTestPlugin() throws Exception { + super.setUpTestPlugin(); allowGlobalCapabilities(REGISTERED_USERS, SaveReportCapability.getName(NAME)); Properties p = new Properties();
diff --git a/tools/bzl/genrule2.bzl b/tools/bzl/genrule2.bzl new file mode 100644 index 0000000..61c4e18 --- /dev/null +++ b/tools/bzl/genrule2.bzl
@@ -0,0 +1,3 @@ +load("@com_googlesource_gerrit_bazlets//tools:genrule2.bzl", _genrule2 = "genrule2") + +genrule2 = _genrule2
diff --git a/tools/bzl/js.bzl b/tools/bzl/js.bzl new file mode 100644 index 0000000..0f9e367 --- /dev/null +++ b/tools/bzl/js.bzl
@@ -0,0 +1,3 @@ +load("@com_googlesource_gerrit_bazlets//tools:js.bzl", _polygerrit_plugin = "polygerrit_plugin") + +polygerrit_plugin = _polygerrit_plugin