From 0022dc2545086de4e205f99117d2de87eec76f3e Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Fri, 18 Feb 2022 18:40:54 +0000 Subject: [PATCH] Use Gitea for Gerrit's code browser URLs This is a reimplementation of earlier change I8efefe365f3b9ebe97c8c2ce322fa8c6f3b70b3a to link out to Gitea instead of Gerrit's local Gitiles plugin. This should reduce the complexity of what we're hosting on the Gerrit server, while at the same time be less confusing for search engines and users. Configure the Gitiles plugin to no longer take over Gerrit weblinks, and a followup change will block access to its URL base path entirely. Change-Id: I7e194fe5c907b39d53fd0663e06cbfd33a3ae410 --- playbooks/roles/gerrit/files/gitiles.config | 2 ++ playbooks/roles/gerrit/tasks/main.yaml | 8 ++++++++ .../roles/gerrit/templates/gerrit.config.j2 | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 playbooks/roles/gerrit/files/gitiles.config diff --git a/playbooks/roles/gerrit/files/gitiles.config b/playbooks/roles/gerrit/files/gitiles.config new file mode 100644 index 0000000000..312c59ce40 --- /dev/null +++ b/playbooks/roles/gerrit/files/gitiles.config @@ -0,0 +1,2 @@ +[gerrit] + noWebLinks = true diff --git a/playbooks/roles/gerrit/tasks/main.yaml b/playbooks/roles/gerrit/tasks/main.yaml index f23b486b8c..b7f5fb4386 100644 --- a/playbooks/roles/gerrit/tasks/main.yaml +++ b/playbooks/roles/gerrit/tasks/main.yaml @@ -215,6 +215,14 @@ group: '{{ gerrit_user_name }}' mode: 0644 +- name: Write Gitiles plugin configuration file + copy: + src: gitiles.config + dest: '{{ gerrit_site_dir }}/etc/gitiles.config' + owner: '{{ gerrit_user_name }}' + group: '{{ gerrit_user_name }}' + mode: 0644 + - name: Write manage-projects script template: src: "manage-projects.j2" diff --git a/playbooks/roles/gerrit/templates/gerrit.config.j2 b/playbooks/roles/gerrit/templates/gerrit.config.j2 index 8ee10a1a74..5d0ff3ac8c 100644 --- a/playbooks/roles/gerrit/templates/gerrit.config.j2 +++ b/playbooks/roles/gerrit/templates/gerrit.config.j2 @@ -131,13 +131,19 @@ system = Storyboard [plugin "javamelody"] allowTopMenu = false -# Gerrit upstream hardcodes a .git extension for cgit. -# The cgit settings below are the same just without the -# .git extension. +# Custom code browser linking for Gitea. [gitweb] - type = gitweb - cgi = /usr/share/gitweb/gitweb.cgi - revision = "?p=${project}.git;a=commitdiff;h=${commit}" + branch = "${project}/src/branch/${branch}" + file = "${project}/src/commit/${hash}/${file}" + filehistory = "${project}/commits/branch/${branch}/${file}" + linkname = gitea + project = "${project}" + revision = "${project}/commit/${commit}" + roottree = "${project}/src/commit/${commit}" + type = custom + urlEncode = false + tag = "${project}/src/tag/${tag}" + url = "https://opendev.org/" [index] type = LUCENE threads = 8