emacs: Comment Gerrit URL bugfix.
Previously the host was hardcoded as
"chromium-review.googlesource.com" when generating links to the webUI
comments. This has now been remedied.
BUG=chromium:1111775
TEST=Tested links generated by gerrit-comments sections ui.
Change-Id: I686a40082885f55fc86ddc164e120c322cd14fb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/2331865
Reviewed-by: Sean McAllister <smcallis@google.com>
Tested-by: Aaron Massey <aaronmassey@chromium.org>
Commit-Queue: Aaron Massey <aaronmassey@chromium.org>
diff --git a/contrib/emacs/gerrit-section.el b/contrib/emacs/gerrit-section.el
index 779436c..dc3d6ed 100644
--- a/contrib/emacs/gerrit-section.el
+++ b/contrib/emacs/gerrit-section.el
@@ -216,7 +216,8 @@
;; TODO buttonize link.
(propertize
(format
- "https://chromium-review.googlesource.com/c/%s/+/%s/%s/%s#%s"
+ "https://%s/c/%s/+/%s/%s/%s#%s"
+ (gethash (gethash "change_id" change) gerrit--change-to-host)
(url-hexify-string (gethash "project" change))
(gethash "_number" change)
;; Default is nil if comments only on a single patch.
diff --git a/contrib/emacs/gerrit.el b/contrib/emacs/gerrit.el
index a810946..322f5c1 100644
--- a/contrib/emacs/gerrit.el
+++ b/contrib/emacs/gerrit.el
@@ -40,6 +40,12 @@
Default is repo_root_path/.repo/manifests/default.xml")
+(defvar gerrit--change-to-host
+ (make-hash-table :test 'equal)
+ "Map showing => host.
+Needed for generating links.")
+
+
(defun gerrit-init ()
"Initialize Repo Gerrit state."
(unless gerrit-repo-manifest
@@ -117,6 +123,9 @@
Only fetches recent changes for open CLs."
(let ((out-map (make-hash-table :test 'equal)))
(loop for change across (gerrit--fetch-recent-changes host) do
+ (setf (gethash (gethash "change_id" change)
+ gerrit--change-to-host)
+ host)
(setf (gethash change out-map)
(gerrit--fetch-comments host change)))
out-map))