From e673e0361fb772e552f8df7206dd7dbe677462dc Mon Sep 17 00:00:00 2001 From: Tao Zhou Date: Thu, 8 Aug 2019 13:31:36 +0200 Subject: [PATCH 01/11] Fix anchor tag for settings page Also add location-change listener to support polymer 2 Bug: Issue 10733 Change-Id: I70771b95da0b40913c827ef45929dab346fb298e --- .../gr-settings-view/gr-settings-view.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js index 5bb4061490..8e1b5a364c 100644 --- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js +++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js @@ -144,6 +144,9 @@ ], attached() { + // Polymer 2: anchor tag won't work on shadow DOM + // we need to manually calling scrollIntoView when hash changed + this.listen(window, 'location-change', '_handleLocationChange'); this.fire('title-change', {title: 'Settings'}); const promises = [ @@ -193,9 +196,28 @@ this._loadingPromise = Promise.all(promises).then(() => { this._loading = false; + + // Handle anchor tag for initial load + this._handleLocationChange(); }); }, + detach() { + this.unlisten(window, 'location-change', '_handleLocationChange'); + }, + + _handleLocationChange() { + // Handle anchor tag after dom attached + const urlHash = window.location.hash; + if (urlHash) { + // Use shadowRoot for Polymer 2 + const elem = (this.shadowRoot || document).querySelector(urlHash); + if (elem) { + elem.scrollIntoView(); + } + } + }, + reloadAccountDetail() { Promise.all([ this.$.accountInfo.loadData(), From 31298e635e9a1561220a5a1ef5f30d4c772e984f Mon Sep 17 00:00:00 2001 From: Paladox none Date: Thu, 8 Aug 2019 15:15:11 +0000 Subject: [PATCH 02/11] detach -> detached Change-Id: I05acb0a65ad3942bbd1f7943e52747c841e4afa4 --- .../app/elements/settings/gr-settings-view/gr-settings-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js index 8e1b5a364c..fdc071b6de 100644 --- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js +++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js @@ -202,7 +202,7 @@ }); }, - detach() { + detached() { this.unlisten(window, 'location-change', '_handleLocationChange'); }, From 841d0e326ed1ae01c7bb0f300dcf5cc514339c58 Mon Sep 17 00:00:00 2001 From: Ole Rehmsen Date: Tue, 18 Jun 2019 09:35:42 +0200 Subject: [PATCH 03/11] Upgrade Go Bazel rules to the latest version Fixes running ./polygerrit-ui/run-server.sh in stable-2.16. bazel 1.7 has a breaking change that requires an update of the go rules (https://github.com/bazelbuild/bazel/issues/7793). Bug: Issue 11271 Change-Id: I43c375315cda7112df43f93b0c274aecdf7171ab (cherry picked from commit 038ab176777734bc33c2a2a17d05a9e86a057a22) --- WORKSPACE | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index fe7cc17ec1..6ecf3b6bba 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -84,8 +84,11 @@ closure_repositories( # Golang support for PolyGerrit local dev server. http_archive( name = "io_bazel_rules_go", - sha256 = "6776d68ebb897625dead17ae510eac3d5f6342367327875210df44dbe2aeeb19", - url = "https://github.com/bazelbuild/rules_go/releases/download/0.17.1/rules_go-0.17.1.tar.gz", + sha256 = "f04d2373bcaf8aa09bccb08a98a57e721306c8f6043a2a0ee610fd6853dcde3d", + urls = [ + "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz", + "https://github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz", + ], ) load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") From 8a093ffd8c58714b420c3df535b3ac660f802bbc Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 5 Aug 2019 22:21:57 +0900 Subject: [PATCH 04/11] ListChangeComments: Extend ListChangeDrafts Refactor ListChangeComments to extend ListChangeDrafts, reducing repeated code and making it easier to add further functionality that is common to both. This follows the same pattern as ListRevision{Drafts,Comments}. Change-Id: Iddb06009fbba468750c1eb31afbe8009c6c7b27b --- .../server/change/ListChangeComments.java | 37 ++++++++----------- .../server/change/ListChangeDrafts.java | 30 ++++++++++----- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeComments.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeComments.java index 0048657004..f7a6ef3d7f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeComments.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeComments.java @@ -14,9 +14,7 @@ package com.google.gerrit.server.change; -import com.google.gerrit.extensions.common.CommentInfo; -import com.google.gerrit.extensions.restapi.AuthException; -import com.google.gerrit.extensions.restapi.RestReadView; +import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.CommentsUtil; import com.google.gerrit.server.query.change.ChangeData; @@ -24,15 +22,9 @@ import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; -import java.util.List; -import java.util.Map; @Singleton -public class ListChangeComments implements RestReadView { - private final Provider db; - private final ChangeData.Factory changeDataFactory; - private final Provider commentJson; - private final CommentsUtil commentsUtil; +public class ListChangeComments extends ListChangeDrafts { @Inject ListChangeComments( @@ -40,21 +32,22 @@ public class ListChangeComments implements RestReadView { ChangeData.Factory changeDataFactory, Provider commentJson, CommentsUtil commentsUtil) { - this.db = db; - this.changeDataFactory = changeDataFactory; - this.commentJson = commentJson; - this.commentsUtil = commentsUtil; + super(db, changeDataFactory, commentJson, commentsUtil); } @Override - public Map> apply(ChangeResource rsrc) - throws AuthException, OrmException { + protected Iterable listComments(ChangeResource rsrc) throws OrmException { ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes()); - return commentJson - .get() - .setFillAccounts(true) - .setFillPatchSet(true) - .newCommentFormatter() - .format(commentsUtil.publishedByChange(db.get(), cd.notes())); + return commentsUtil.publishedByChange(db.get(), cd.notes()); + } + + @Override + protected boolean includeAuthorInfo() { + return true; + } + + @Override + public boolean requireAuthentication() { + return false; } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java index 02713de9a6..f0b693383c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java @@ -30,10 +30,10 @@ import java.util.Map; @Singleton public class ListChangeDrafts implements RestReadView { - private final Provider db; - private final ChangeData.Factory changeDataFactory; - private final Provider commentJson; - private final CommentsUtil commentsUtil; + protected final Provider db; + protected final ChangeData.Factory changeDataFactory; + protected final Provider commentJson; + protected final CommentsUtil commentsUtil; @Inject ListChangeDrafts( @@ -47,20 +47,30 @@ public class ListChangeDrafts implements RestReadView { this.commentsUtil = commentsUtil; } + protected Iterable listComments(ChangeResource rsrc) throws OrmException { + ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes()); + return commentsUtil.draftByChangeAuthor(db.get(), cd.notes(), rsrc.getUser().getAccountId()); + } + + protected boolean includeAuthorInfo() { + return false; + } + + public boolean requireAuthentication() { + return true; + } + @Override public Map> apply(ChangeResource rsrc) throws AuthException, OrmException { - if (!rsrc.getUser().isIdentifiedUser()) { + if (requireAuthentication() && !rsrc.getUser().isIdentifiedUser()) { throw new AuthException("Authentication required"); } - ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes()); - List drafts = - commentsUtil.draftByChangeAuthor(db.get(), cd.notes(), rsrc.getUser().getAccountId()); return commentJson .get() - .setFillAccounts(false) + .setFillAccounts(includeAuthorInfo()) .setFillPatchSet(true) .newCommentFormatter() - .format(drafts); + .format(listComments(rsrc)); } } From 7d4f5297b25b8b2f84a848393692f9f3996c3b0d Mon Sep 17 00:00:00 2001 From: Marcin Czech Date: Sat, 10 Aug 2019 11:45:10 +0100 Subject: [PATCH 05/11] Update git submodules * Update plugins/replication from branch 'stable-2.16' to 29875954b9e766620f31991f425020ae22ade485 - Add replication refs-filtering before push Add ability to filter out refs before being pushed for replication to remote instance. This will help to prevent split-brain issue by allowing us to create filter in multi-site plugin to stop the out of sync instance from overriding the changes of the instance that is up to date. Bug: Issue 11175 Change-Id: I99a7cb4fb2f231626d50abc7d90bb3d79c23861a --- plugins/replication | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/replication b/plugins/replication index d33615ca4e..29875954b9 160000 --- a/plugins/replication +++ b/plugins/replication @@ -1 +1 @@ -Subproject commit d33615ca4eae3f73b8b90e46edefc1584ebf458d +Subproject commit 29875954b9e766620f31991f425020ae22ade485 From f841099db56275c5eb24257c76e22dcf36fbc848 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 5 Aug 2019 22:32:08 +0900 Subject: [PATCH 06/11] ChangeApi: Add methods to get change comments/drafts as list The current API allows to get all change comments and drafts, but as a map of path names to lists of comment infos; the paths are not set in the comment infos. This is not convenient for callers that just want a list of all comments on the change; they have to transform the map to a list, setting the path field on each element. Add new methods that return the comments as a plain list, with paths already set. This reduces the amount of code clients need to write. Note that such methods already exist on the revision API. Change-Id: Ic3fd48347d195ebbe361d32167dbaacb572f066d --- .../acceptance/server/change/CommentsIT.java | 28 +++++++++++++++++++ .../extensions/api/changes/ChangeApi.java | 28 +++++++++++++++++++ .../server/api/changes/ChangeApiImpl.java | 18 ++++++++++++ .../server/change/ListChangeDrafts.java | 15 ++++++++-- 4 files changed, 87 insertions(+), 2 deletions(-) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java index 6fcb893747..1c79340f1b 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/CommentsIT.java @@ -119,6 +119,11 @@ public class CommentsIT extends AbstractDaemonTest { assertThat(result).hasSize(1); CommentInfo actual = Iterables.getOnlyElement(result.get(comment.path)); assertThat(comment).isEqualTo(infoToDraft(path).apply(actual)); + + List list = getDraftCommentsAsList(changeId); + assertThat(list).hasSize(1); + actual = list.get(0); + assertThat(comment).isEqualTo(infoToDraft(path).apply(actual)); } } @@ -141,6 +146,10 @@ public class CommentsIT extends AbstractDaemonTest { assertThat(result).hasSize(1); assertThat(Lists.transform(result.get(path), infoToDraft(path))) .containsExactly(c1, c2, c3, c4); + + List list = getDraftCommentsAsList(changeId); + assertThat(list).hasSize(4); + assertThat(Lists.transform(list, infoToDraft(path))).containsExactly(c1, c2, c3, c4); } } @@ -243,6 +252,9 @@ public class CommentsIT extends AbstractDaemonTest { assertThat(result).isNotEmpty(); assertThat(Lists.transform(result.get(file), infoToInput(file))) .containsExactly(c1, c2, c3, c4); + + List list = getPublishedCommentsAsList(changeId); + assertThat(Lists.transform(list, infoToInput(file))).containsExactly(c1, c2, c3, c4); } // for the commit message comments on the auto-merge are not possible @@ -261,6 +273,9 @@ public class CommentsIT extends AbstractDaemonTest { Map> result = getPublishedComments(changeId, revId); assertThat(result).isNotEmpty(); assertThat(Lists.transform(result.get(file), infoToInput(file))).containsExactly(c1, c2, c3); + + List list = getPublishedCommentsAsList(changeId); + assertThat(Lists.transform(list, infoToInput(file))).containsExactly(c1, c2, c3); } } @@ -285,6 +300,7 @@ public class CommentsIT extends AbstractDaemonTest { String changeId = r.getChangeId(); String revId = r.getCommit().getName(); assertThat(getPublishedComments(changeId, revId)).isEmpty(); + assertThat(getPublishedCommentsAsList(changeId)).isEmpty(); List expectedComments = new ArrayList<>(); for (Integer line : lines) { @@ -301,6 +317,10 @@ public class CommentsIT extends AbstractDaemonTest { List actualComments = result.get(file); assertThat(Lists.transform(actualComments, infoToInput(file))) .containsExactlyElementsIn(expectedComments); + + List list = getPublishedCommentsAsList(changeId); + assertThat(Lists.transform(list, infoToInput(file))) + .containsExactlyElementsIn(expectedComments); } @Test @@ -1101,11 +1121,19 @@ public class CommentsIT extends AbstractDaemonTest { return gApi.changes().id(changeId).revision(revId).comments(); } + private List getPublishedCommentsAsList(String changeId) throws Exception { + return gApi.changes().id(changeId).commentsAsList(); + } + private Map> getDraftComments(String changeId, String revId) throws Exception { return gApi.changes().id(changeId).revision(revId).drafts(); } + private List getDraftCommentsAsList(String changeId) throws Exception { + return gApi.changes().id(changeId).draftsAsList(); + } + private Map> getPublishedComments(String changeId) throws Exception { return gApi.changes().id(changeId).comments(); } diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java index 5183a89e38..202a67d47d 100644 --- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/changes/ChangeApi.java @@ -262,6 +262,15 @@ public interface ChangeApi { */ Map> comments() throws RestApiException; + /** + * Get all published comments on a change as a list. + * + * @return comments as a list; comments have the {@code revision} field set to indicate their + * patch set. + * @throws RestApiException + */ + List commentsAsList() throws RestApiException; + /** * Get all robot comments on a change. * @@ -280,6 +289,15 @@ public interface ChangeApi { */ Map> drafts() throws RestApiException; + /** + * Get all draft comments for the current user on a change as a list. + * + * @return drafts as a list; comments have the {@code revision} field set to indicate their patch + * set. + * @throws RestApiException + */ + List draftsAsList() throws RestApiException; + ChangeInfo check() throws RestApiException; ChangeInfo check(FixInput fix) throws RestApiException; @@ -533,6 +551,11 @@ public interface ChangeApi { throw new NotImplementedException(); } + @Override + public List commentsAsList() throws RestApiException { + throw new NotImplementedException(); + } + @Override public Map> robotComments() throws RestApiException { throw new NotImplementedException(); @@ -543,6 +566,11 @@ public interface ChangeApi { throw new NotImplementedException(); } + @Override + public List draftsAsList() throws RestApiException { + throw new NotImplementedException(); + } + @Override public ChangeInfo check() throws RestApiException { throw new NotImplementedException(); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java index 447fdf4f1b..373a4253c9 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/api/changes/ChangeApiImpl.java @@ -619,6 +619,15 @@ class ChangeApiImpl implements ChangeApi { } } + @Override + public List commentsAsList() throws RestApiException { + try { + return listComments.getComments(change); + } catch (Exception e) { + throw asRestApiException("Cannot get comments", e); + } + } + @Override public Map> robotComments() throws RestApiException { try { @@ -637,6 +646,15 @@ class ChangeApiImpl implements ChangeApi { } } + @Override + public List draftsAsList() throws RestApiException { + try { + return listDrafts.getComments(change); + } catch (Exception e) { + throw asRestApiException("Cannot get drafts", e); + } + } + @Override public ChangeInfo check() throws RestApiException { try { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java index f0b693383c..22fc5ea171 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ListChangeDrafts.java @@ -20,6 +20,7 @@ import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.reviewdb.client.Comment; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.CommentsUtil; +import com.google.gerrit.server.change.CommentJson.CommentFormatter; import com.google.gerrit.server.query.change.ChangeData; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; @@ -66,11 +67,21 @@ public class ListChangeDrafts implements RestReadView { if (requireAuthentication() && !rsrc.getUser().isIdentifiedUser()) { throw new AuthException("Authentication required"); } + return getCommentFormatter().format(listComments(rsrc)); + } + + public List getComments(ChangeResource rsrc) throws AuthException, OrmException { + if (requireAuthentication() && !rsrc.getUser().isIdentifiedUser()) { + throw new AuthException("Authentication required"); + } + return getCommentFormatter().formatAsList(listComments(rsrc)); + } + + private CommentFormatter getCommentFormatter() { return commentJson .get() .setFillAccounts(includeAuthorInfo()) .setFillPatchSet(true) - .newCommentFormatter() - .format(listComments(rsrc)); + .newCommentFormatter(); } } From bc228f5e3db1e22077435cb1d6fe6685b6e48ab6 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 12 Aug 2019 14:47:18 +0900 Subject: [PATCH 07/11] AuthRequest: Fix Javadoc for return values The methods' javadocs state that the return is 'null', but this was changed some time ago to be Optional.empty(). Change-Id: I8f883cf7d79efb848d70043d23ecc707cfcdf1d0 --- java/com/google/gerrit/server/auth/AuthRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com/google/gerrit/server/auth/AuthRequest.java b/java/com/google/gerrit/server/auth/AuthRequest.java index c6222f8cb7..d155f894d6 100644 --- a/java/com/google/gerrit/server/auth/AuthRequest.java +++ b/java/com/google/gerrit/server/auth/AuthRequest.java @@ -31,7 +31,7 @@ public abstract class AuthRequest { /** * Returns the username to be authenticated. * - * @return username for authentication or null for anonymous access. + * @return username for authentication or {@code empty} for anonymous access. */ public final Optional getUsername() { return username; @@ -40,7 +40,7 @@ public abstract class AuthRequest { /** * Returns the user's credentials * - * @return user's credentials or null + * @return user's credentials or {@code empty}. */ public final Optional getPassword() { return password; From 231dfc261a3ca58ba6ede8008234559b4cc5d3ac Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Mon, 12 Aug 2019 06:57:04 +0100 Subject: [PATCH 08/11] Update git submodules * Update plugins/replication from branch 'stable-2.16' to 23037c51be039e2e94d9f4fd54d4d38cdc88ac82 - Revert "Revert "Do not reload config when queue is not ready"" This reverts commit bcb15e00b3bd8804417d7401cff12a941bdb8aee. The test that was previously failing on stable-3.0 has been fixed with Change-Id: I2bef00e701 and thus does not represent anymore an impediment for getting this fix merged in stable-2.16 and stable-3.0. Change-Id: I936e3547ff4533850d538fe6b9fada7437bf4e49 --- plugins/replication | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/replication b/plugins/replication index 29875954b9..23037c51be 160000 --- a/plugins/replication +++ b/plugins/replication @@ -1 +1 @@ -Subproject commit 29875954b9e766620f31991f425020ae22ade485 +Subproject commit 23037c51be039e2e94d9f4fd54d4d38cdc88ac82 From c928ec3adc3286bf740d5c97b6ef0368ce29ee6a Mon Sep 17 00:00:00 2001 From: Irina Iancu Date: Fri, 9 Aug 2019 14:03:02 +0200 Subject: [PATCH 09/11] Migrate from old-style legacy .java provider to the new JavaInfo. Preparation of flipping the flag --incompatible_disallow_legacy_java_provider in bazel. Change-Id: I5e68886130a5de6b6180bea3f85aec320327ded3 --- tools/bzl/pkg_war.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/bzl/pkg_war.bzl b/tools/bzl/pkg_war.bzl index 72ed9f878f..c92b5c86f3 100644 --- a/tools/bzl/pkg_war.bzl +++ b/tools/bzl/pkg_war.bzl @@ -77,8 +77,8 @@ def _war_impl(ctx): # Add lib transitive_libs = [] for j in ctx.attr.libs: - if hasattr(j, "java"): - transitive_libs.append(j.java.transitive_runtime_deps) + if hasattr(j, "JavaInfo"): + transitive_libs.append(j[JavaInfo].transitive_runtime_deps) elif hasattr(j, "files"): transitive_libs.append(j.files) @@ -90,7 +90,7 @@ def _war_impl(ctx): # Add pgm lib transitive_pgmlibs = [] for j in ctx.attr.pgmlibs: - transitive_pgmlibs.append(j.java.transitive_runtime_deps) + transitive_pgmlibs.append(j[JavaInfo].transitive_runtime_deps) transitive_pgmlib_deps = depset(transitive = transitive_pgmlibs) for dep in transitive_pgmlib_deps.to_list(): From 3aca363032b6ea22cfa977877d12718c1ae8352c Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Tue, 13 Aug 2019 08:07:13 +0100 Subject: [PATCH 10/11] Catch all exceptions for reporting on Schema_130 migration When migrating all projects configs during Schema_130 migration, any unexpected exception would not show the name of the impacted repo, causing a headache for the Gerrit admin that is willing to migrate. Make sure the impacted repository and the exception caused are always displayed so that the Gerrit admin can have an easier life understanding what happens. Change-Id: I133c435d9e6d8677964102b26740d55d687764c6 --- .../main/java/com/google/gerrit/server/schema/Schema_130.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_130.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_130.java index 52f90b5b4d..afb62faf3a 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_130.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_130.java @@ -25,10 +25,8 @@ import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; -import java.io.IOException; import java.util.SortedSet; import java.util.TreeSet; -import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; @@ -66,7 +64,7 @@ public class Schema_130 extends SchemaVersion { repoUpgraded.add(projectName); } cfg.save(serverUser, COMMIT_MSG); - } catch (ConfigInvalidException | IOException ex) { + } catch (Exception ex) { throw new OrmException("Cannot migrate project " + projectName, ex); } } From 3edd41d55cf391f7db762579752af14c92022c48 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 14 Aug 2019 12:54:10 +0900 Subject: [PATCH 11/11] Revert "Migrate from old-style legacy .java provider to the new JavaInfo." As a result of this change the contents of the war file are different, for example the postgresql library: Before: WEB-INF/lib/postgresql-42.2.5.jar After: WEB-INF/lib/libpostgresql.jar This causes the initialization of the site to fail when using the postgres DB: fatal: Driver class org.postgresql.Driver not available fatal: Cannot connect to SQL database This reverts commit c928ec3adc3286bf740d5c97b6ef0368ce29ee6a. Change-Id: I3fd0695f12c87fe4a049ee30739ef8674b587c6e --- tools/bzl/pkg_war.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/bzl/pkg_war.bzl b/tools/bzl/pkg_war.bzl index c92b5c86f3..72ed9f878f 100644 --- a/tools/bzl/pkg_war.bzl +++ b/tools/bzl/pkg_war.bzl @@ -77,8 +77,8 @@ def _war_impl(ctx): # Add lib transitive_libs = [] for j in ctx.attr.libs: - if hasattr(j, "JavaInfo"): - transitive_libs.append(j[JavaInfo].transitive_runtime_deps) + if hasattr(j, "java"): + transitive_libs.append(j.java.transitive_runtime_deps) elif hasattr(j, "files"): transitive_libs.append(j.files) @@ -90,7 +90,7 @@ def _war_impl(ctx): # Add pgm lib transitive_pgmlibs = [] for j in ctx.attr.pgmlibs: - transitive_pgmlibs.append(j[JavaInfo].transitive_runtime_deps) + transitive_pgmlibs.append(j.java.transitive_runtime_deps) transitive_pgmlib_deps = depset(transitive = transitive_pgmlibs) for dep in transitive_pgmlib_deps.to_list():