From 77be22549a436d0869d8f8c91c09e5b3219567b7 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Fri, 27 Nov 2020 17:39:35 +0000 Subject: chore(3p/gerrit): update to latest upstream HEAD Change-Id: Ia7b17ca83ace164881a4dd8b0288741489bc467c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2164 Tested-by: BuildkiteCI Reviewed-by: glittershark Reviewed-by: tazjin --- .../0001-Use-detzip-in-download_bower.py.patch | 6 +-- third_party/gerrit/0002-Syntax-highlight-nix.patch | 28 +++++------ .../gerrit/0003-Syntax-highlight-rules.pl.patch | 48 +++++++++--------- .../gerrit/0004-Add-titles-to-CLs-over-HTTP.patch | 57 ++++++++++------------ ...local-fonts-always-assume-Gerrit-is-mount.patch | 8 +-- .../gerrit/0006-Always-use-Google-Fonts.patch | 10 ++-- ...7-Fix-gr-hovercard-behavior-under-Firefox.patch | 35 ------------- third_party/gerrit/default.nix | 30 +++--------- 8 files changed, 86 insertions(+), 136 deletions(-) delete mode 100644 third_party/gerrit/0007-Fix-gr-hovercard-behavior-under-Firefox.patch (limited to 'third_party/gerrit') diff --git a/third_party/gerrit/0001-Use-detzip-in-download_bower.py.patch b/third_party/gerrit/0001-Use-detzip-in-download_bower.py.patch index 7830b0e479ef..62d830c4d1db 100644 --- a/third_party/gerrit/0001-Use-detzip-in-download_bower.py.patch +++ b/third_party/gerrit/0001-Use-detzip-in-download_bower.py.patch @@ -1,7 +1,7 @@ -From c88d8c133d2f50451c7fb73592db4a000b87f15f Mon Sep 17 00:00:00 2001 +From b8e1242655d308377f28c9bfcca2fe578e7093bb Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 2 Jul 2020 23:02:09 +0100 -Subject: [PATCH 1/7] Use detzip in download_bower.py +Subject: [PATCH 1/6] Use detzip in download_bower.py --- tools/js/download_bower.py | 2 +- @@ -21,5 +21,5 @@ index 1df4b826bc..65bda74082 100755 if args.s: -- -2.27.0 +2.29.2 diff --git a/third_party/gerrit/0002-Syntax-highlight-nix.patch b/third_party/gerrit/0002-Syntax-highlight-nix.patch index 4353f1e4774d..a87529d8c84a 100644 --- a/third_party/gerrit/0002-Syntax-highlight-nix.patch +++ b/third_party/gerrit/0002-Syntax-highlight-nix.patch @@ -1,24 +1,24 @@ -From 1310ad5e56248bf216774cd13e828ba76e0c6f65 Mon Sep 17 00:00:00 2001 +From 18a008f8bddfa529296357620bbd9a97de6b2879 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 2 Jul 2020 23:02:32 +0100 -Subject: [PATCH 2/7] Syntax highlight nix +Subject: [PATCH 2/6] Syntax highlight nix --- - .../app/elements/diff/gr-syntax-layer/gr-syntax-layer.js | 1 + + .../app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts | 1 + 1 file changed, 1 insertion(+) -diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js -index 6399c4a469..480d2946c3 100644 ---- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js -+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js -@@ -99,6 +99,7 @@ const LANGUAGE_MAP = { - 'text/x-vhdl': 'vhdl', - 'text/x-yaml': 'yaml', - 'text/vbscript': 'vbscript', -+ 'application/x-mix-transfer': 'nix', - }; +diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts +index f5e5e047bc..0c3bb40ce4 100644 +--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts ++++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts +@@ -105,6 +105,7 @@ const LANGUAGE_MAP = new Map([ + ['text/x-vhdl', 'vhdl'], + ['text/x-yaml', 'yaml'], + ['text/vbscript', 'vbscript'], ++ ['application/x-mix-transfer', 'nix'], + ]); const ASYNC_DELAY = 10; -- -2.27.0 +2.29.2 diff --git a/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch b/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch index 3b87dc14f2bc..a3165444237c 100644 --- a/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch +++ b/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch @@ -1,44 +1,46 @@ -From a8dad8e63a1be32f473e96c6c7530a70d368369f Mon Sep 17 00:00:00 2001 +From 9358b1cdd5f13e6638030446880f731785ca38f1 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 2 Jul 2020 23:02:43 +0100 -Subject: [PATCH 3/7] Syntax highlight rules.pl +Subject: [PATCH 3/6] Syntax highlight rules.pl --- - .../elements/diff/gr-syntax-layer/gr-syntax-layer.js | 10 ++++++++++ - 1 file changed, 10 insertions(+) + .../diff/gr-syntax-layer/gr-syntax-layer.ts | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) -diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js -index 480d2946c3..b2020c24bd 100644 ---- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js -+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js -@@ -103,6 +103,10 @@ const LANGUAGE_MAP = { - }; +diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts +index 0c3bb40ce4..ace253da30 100644 +--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts ++++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.ts +@@ -109,6 +109,10 @@ const LANGUAGE_MAP = new Map([ + ]); const ASYNC_DELAY = 10; -+const FILENAME_OVERRIDES = { -+ 'rules.pl': 'prolog', -+}; ++const FILENAME_OVERRIDES = new Map([ ++ ['rules.pl', 'prolog'], ++]); + - const CLASS_SAFELIST = { - 'gr-diff gr-syntax gr-syntax-attr': true, - 'gr-diff gr-syntax gr-syntax-attribute': true, -@@ -234,10 +238,16 @@ class GrSyntaxLayer extends GestureEventListeners( + const CLASS_SAFELIST = new Set([ + 'gr-diff gr-syntax gr-syntax-attr', + 'gr-diff gr-syntax gr-syntax-attribute', +@@ -258,10 +262,17 @@ export class GrSyntaxLayer } } -+ _basename(filename) { ++ _basename(filename: string): string { + const pieces = filename.split(/\//); + return pieces[pieces.length-1]; + } + - _getLanguage(diffFileMetaInfo) { + _getLanguage(metaInfo: DiffFileMetaInfo) { // The Gerrit API provides only content-type, but for other users of // gr-diff it may be more convenient to specify the language directly. - return diffFileMetaInfo.language || -+ FILENAME_OVERRIDES[this._basename(diffFileMetaInfo.name)] || - LANGUAGE_MAP[diffFileMetaInfo.content_type]; +- return metaInfo.language ?? LANGUAGE_MAP.get(metaInfo.content_type); ++ return metaInfo.language ?? ++ FILENAME_OVERRIDES.get(this._basename(metaInfo.name)) ?? ++ LANGUAGE_MAP.get(metaInfo.content_type); } + /** -- -2.27.0 +2.29.2 diff --git a/third_party/gerrit/0004-Add-titles-to-CLs-over-HTTP.patch b/third_party/gerrit/0004-Add-titles-to-CLs-over-HTTP.patch index d0d1b52c686a..b1ac119927ed 100644 --- a/third_party/gerrit/0004-Add-titles-to-CLs-over-HTTP.patch +++ b/third_party/gerrit/0004-Add-titles-to-CLs-over-HTTP.patch @@ -1,30 +1,30 @@ -From 61035d1e81884390708675ab994e0e7210659883 Mon Sep 17 00:00:00 2001 +From ad4564c31401a900702fca6e3f673badbfbdf9d9 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 2 Jul 2020 23:03:02 +0100 -Subject: [PATCH 4/7] Add titles to CLs over HTTP +Subject: [PATCH 4/6] Add titles to CLs over HTTP --- - .../gerrit/httpd/raw/IndexHtmlUtil.java | 14 +++- + .../gerrit/httpd/raw/IndexHtmlUtil.java | 13 +++- .../google/gerrit/httpd/raw/IndexServlet.java | 7 +- .../google/gerrit/httpd/raw/StaticModule.java | 5 +- .../gerrit/httpd/raw/TitleComputer.java | 67 +++++++++++++++++++ .../gerrit/httpd/raw/PolyGerritIndexHtml.soy | 4 +- - 5 files changed, 89 insertions(+), 8 deletions(-) + 5 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 java/com/google/gerrit/httpd/raw/TitleComputer.java diff --git a/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java b/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java -index cddaea4aaf..d5f43de025 100644 +index 77d02c16d0..3b2cae702a 100644 --- a/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java +++ b/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java -@@ -42,6 +42,7 @@ import java.util.Arrays; +@@ -38,6 +38,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.function.Function; - import java.util.regex.Matcher; -@@ -110,7 +111,8 @@ public class IndexHtmlUtil { + +@@ -58,13 +59,14 @@ public class IndexHtmlUtil { String faviconPath, Map urlParameterMap, Function urlInScriptTagOrdainer, @@ -34,37 +34,34 @@ index cddaea4aaf..d5f43de025 100644 throws URISyntaxException, RestApiException { ImmutableMap.Builder data = ImmutableMap.builder(); data.putAll( -@@ -121,7 +123,7 @@ public class IndexHtmlUtil { - urlParameterMap, - urlInScriptTagOrdainer, - requestedURL)) -- .putAll(dynamicTemplateData(gerritApi)); + staticTemplateData( + canonicalURL, cdnPath, faviconPath, urlParameterMap, urlInScriptTagOrdainer)) +- .putAll(dynamicTemplateData(gerritApi, requestedURL)); + .putAll(dynamicTemplateData(gerritApi, requestedURL, titleComputer)); Set enabledExperiments = experimentData(urlParameterMap); if (!enabledExperiments.isEmpty()) { -@@ -131,7 +133,9 @@ public class IndexHtmlUtil { - } +@@ -75,7 +77,9 @@ public class IndexHtmlUtil { /** Returns dynamic parameters of {@code index.html}. */ -- public static ImmutableMap dynamicTemplateData(GerritApi gerritApi) -+ public static ImmutableMap dynamicTemplateData(GerritApi gerritApi, -+ String requestedURL, -+ TitleComputer titleComputer) - throws RestApiException { + public static ImmutableMap dynamicTemplateData( +- GerritApi gerritApi, String requestedURL) throws RestApiException, URISyntaxException { ++ GerritApi gerritApi, ++ String requestedURL, ++ TitleComputer titleComputer) throws RestApiException, URISyntaxException { ImmutableMap.Builder data = ImmutableMap.builder(); Map initialData = new HashMap<>(); -@@ -158,6 +162,10 @@ public class IndexHtmlUtil { + Server serverApi = gerritApi.config().server(); +@@ -126,6 +130,9 @@ public class IndexHtmlUtil { + // Don't render data } - data.put("gerritInitialData", initialData); -+ + Optional title = titleComputer.computeTitle(requestedURL); + title.ifPresent(s -> data.put("title", s)); + + data.put("gerritInitialData", initialData); return data.build(); } - diff --git a/java/com/google/gerrit/httpd/raw/IndexServlet.java b/java/com/google/gerrit/httpd/raw/IndexServlet.java index 97d22701de..089ef4725f 100644 --- a/java/com/google/gerrit/httpd/raw/IndexServlet.java @@ -103,10 +100,10 @@ index 97d22701de..089ef4725f 100644 } catch (URISyntaxException | RestApiException e) { throw new IOException(e); diff --git a/java/com/google/gerrit/httpd/raw/StaticModule.java b/java/com/google/gerrit/httpd/raw/StaticModule.java -index 414a120194..e1b6fb082d 100644 +index 4b2c8a9733..466fbaa27c 100644 --- a/java/com/google/gerrit/httpd/raw/StaticModule.java +++ b/java/com/google/gerrit/httpd/raw/StaticModule.java -@@ -220,11 +220,12 @@ public class StaticModule extends ServletModule { +@@ -221,11 +221,12 @@ public class StaticModule extends ServletModule { HttpServlet getPolyGerritUiIndexServlet( @CanonicalWebUrl @Nullable String canonicalUrl, @GerritServerConfig Config cfg, @@ -195,12 +192,12 @@ index 0000000000..8fd2053ad0 + } +} diff --git a/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy b/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy -index 32ba0bc790..2515c71d6a 100644 +index 000f4e2b5f..fcc26f7f54 100644 --- a/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy +++ b/resources/com/google/gerrit/httpd/raw/PolyGerritIndexHtml.soy @@ -33,10 +33,12 @@ - {@param? preloadChangePage: ?} - {@param? preloadDiffPage: ?} + {@param? defaultDashboardHex: ?} + {@param? dashboardQuery: ?} {@param? userIsAuthenticated: ?} + {@param? title: ?} {\n} @@ -213,5 +210,5 @@ index 32ba0bc790..2515c71d6a 100644 {\n} -- -2.27.0 +2.29.2 diff --git a/third_party/gerrit/0005-When-using-local-fonts-always-assume-Gerrit-is-mount.patch b/third_party/gerrit/0005-When-using-local-fonts-always-assume-Gerrit-is-mount.patch index d62c7f0c577b..03b24b84faca 100644 --- a/third_party/gerrit/0005-When-using-local-fonts-always-assume-Gerrit-is-mount.patch +++ b/third_party/gerrit/0005-When-using-local-fonts-always-assume-Gerrit-is-mount.patch @@ -1,7 +1,7 @@ -From 73edc92dfa584117f6a4373388c9bc47e50a5713 Mon Sep 17 00:00:00 2001 +From dfa0d782edb6b2d789f71a2462ba93e6101b5e4e Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 11 Jul 2020 00:45:57 +0000 -Subject: [PATCH 5/7] When using local fonts, always assume Gerrit is mounted +Subject: [PATCH 5/6] When using local fonts, always assume Gerrit is mounted at the root. --- @@ -9,7 +9,7 @@ Subject: [PATCH 5/7] When using local fonts, always assume Gerrit is mounted 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polygerrit-ui/app/rollup.config.js b/polygerrit-ui/app/rollup.config.js -index db0e2f7159..7bde541405 100644 +index c8e9baa98c..9438504bd8 100644 --- a/polygerrit-ui/app/rollup.config.js +++ b/polygerrit-ui/app/rollup.config.js @@ -50,7 +50,7 @@ const importLocalFontMetaUrlResolver = function() { @@ -22,5 +22,5 @@ index db0e2f7159..7bde541405 100644 return null; } -- -2.27.0 +2.29.2 diff --git a/third_party/gerrit/0006-Always-use-Google-Fonts.patch b/third_party/gerrit/0006-Always-use-Google-Fonts.patch index 87ce3a1b2b60..1b392053537f 100644 --- a/third_party/gerrit/0006-Always-use-Google-Fonts.patch +++ b/third_party/gerrit/0006-Always-use-Google-Fonts.patch @@ -1,7 +1,7 @@ -From f3b85ab3ac139d8ec51c09aa5e0d430d65e35a96 Mon Sep 17 00:00:00 2001 +From def99cd67963afad42bd70f21fd2f626603481e4 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 11 Jul 2020 00:46:13 +0000 -Subject: [PATCH 6/7] Always use Google Fonts. +Subject: [PATCH 6/6] Always use Google Fonts. We're not a corporate, and we're not behind the GFW. Always use Google Fonts, because even though we no longer get the caching benefits (boo, browsers), @@ -11,10 +11,10 @@ it is still a better geographically-distributed CDN. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java b/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java -index d5f43de025..9c68a1d327 100644 +index 3b2cae702a..84ce678b6d 100644 --- a/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java +++ b/java/com/google/gerrit/httpd/raw/IndexHtmlUtil.java -@@ -231,7 +231,7 @@ public class IndexHtmlUtil { +@@ -182,7 +182,7 @@ public class IndexHtmlUtil { if (urlParameterMap.containsKey("ce")) { data.put("polyfillCE", "true"); } @@ -24,5 +24,5 @@ index d5f43de025..9c68a1d327 100644 } -- -2.27.0 +2.29.2 diff --git a/third_party/gerrit/0007-Fix-gr-hovercard-behavior-under-Firefox.patch b/third_party/gerrit/0007-Fix-gr-hovercard-behavior-under-Firefox.patch deleted file mode 100644 index 715c70d70185..000000000000 --- a/third_party/gerrit/0007-Fix-gr-hovercard-behavior-under-Firefox.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 460d4806feef7fdddc8e3b63dec4fa1854fd2561 Mon Sep 17 00:00:00 2001 -From: Luke Granger-Brown -Date: Sat, 25 Jul 2020 23:54:18 +0000 -Subject: [PATCH 7/7] Fix gr-hovercard-behavior under Firefox - -Firefox doesn't implement toElement/fromElement (they're not in the -spec, and were implemented by Chrome apparently for compatibility with -IE), but does implement target and relatedTarget, which are part of -the UI Events spec -(https://w3c.github.io/uievents/#interface-mouseevent). - -Bug: Issue 13175 -Change-Id: I9eeb26c032a38de9d7185749373c7982c796acb2 ---- - .../app/elements/shared/gr-hovercard/gr-hovercard-behavior.js | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.js b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.js -index 04c3166dd5..3d5937b1fa 100644 ---- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.js -+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.js -@@ -209,8 +209,8 @@ export const hovercardBehaviorMixin = superClass => class extends superClass { - // from the hovercard but now hovering over the target (to stop an annoying - // flicker effect), just return. - if (opt_e) { -- if (opt_e.toElement === this || -- (opt_e.fromElement === this && opt_e.toElement === this._target)) { -+ if (opt_e.relatedTarget === this || -+ (opt_e.target === this && opt_e.relatedTarget === this._target)) { - return; - } - } --- -2.27.0 - diff --git a/third_party/gerrit/default.nix b/third_party/gerrit/default.nix index 84804db1e985..8879616310e3 100644 --- a/third_party/gerrit/default.nix +++ b/third_party/gerrit/default.nix @@ -16,7 +16,7 @@ let targetPkgs = pkgs: [ (pkgs.bazel.override { enableNixHacks = true; }) detzip - pkgs.jdk + pkgs.jdk11_headless pkgs.zlib pkgs.python pkgs.curl @@ -28,15 +28,16 @@ let runScript = "/bin/bazel-run"; }; bazel = bazelTop // { override = x: bazelTop; }; - version = "3.2.3-951-gd888625eb5"; + version = "3.3.0-rc7-520-gdef99cd679"; in pkgs.lib.makeOverridable pkgs.buildBazelPackage { - name = "gerrit-${version}"; + pname = "gerrit"; + inherit version; src = pkgs.fetchgit { url = "https://gerrit.googlesource.com/gerrit"; - rev = "d888625eb5e1c91b257c9501924efdd9ae498422"; - sha256 = "15dgjn5xqhvgwnc4klmh2m8f205x1fhchbs8x312lm2g2apdhdcc"; + rev = "d36cf01b0f03eb6a555c915cc9d570e4b07d485b"; + sha256 = "sha256:0a8qnwyhkl8amp34qlnym50787iaxg34k0f44dsyj6qlkj6aqx57"; fetchSubmodules = true; }; patches = [ @@ -56,28 +57,13 @@ pkgs.lib.makeOverridable pkgs.buildBazelPackage { "--disk_cache=" ]; removeRulesCC = false; + fetchConfigured = true; fetchAttrs = { - sha256 = "1f624gb1whmadf7qyv5l2yqw7pgbjlbfyk1gzkrcykhlwsxz9z0f"; + sha256 = "sha256:042m2fzp6hhc76hiyvjakx2bcpbwsbf8gv20d6zifi237dgw6pj3"; preBuild = '' rm .bazelversion ''; - buildPhase = '' - runHook preBuild - - BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \ - USER=homeless-shelter \ - bazel \ - --output_base="$bazelOut" \ - --output_user_root="$bazelUserRoot" \ - build --nobuild \ - --loading_phase_threads=1 \ - $bazelFlags \ - $bazelFetchFlags \ - $bazelTarget - - runHook postBuild - ''; installPhase = '' runHook preInstall -- cgit 1.4.1