From a5095d52bc87e7346a9d9fb3da0628cdcf86101c Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Mon, 27 May 2024 09:44:12 -0700 Subject: [PATCH] Update Gitea to version 1.22 Changes made on our side to make this upgrade happen: * Update the gitea checkout tag to v1.22.1 * Update the golang container version to 1.22 as gitea 1.22 has an undocumented hard dependency on golang 1.22 or newer. * Update our overridden template files to match latest gitea template changes. * Update our app.ini config to switch from [oauth2].ENABLE to [oauth2].ENABLED as the previous config string is deprecated and will be removed in 1.23.0 per: ...es/setting/oauth2.go:124:loadOAuth2From() [E] Deprecation: config option `[oauth2].ENABLE` presents, please use `[oauth2].ENABLED` instead because this fallback will be/has been removed in v1.23.0 The full release notes for this release can be found here: https://github.com/go-gitea/gitea/blob/v1.22.1/CHANGELOG.md I've including the list of breaking changes below with my own annotations on how/whether they affect us. * BREAKING * Improve reverse proxy documents and clarify the AppURL guessing behavior (https://github.com/go-gitea/gitea/pull/31003) (https://github.com/go-gitea/gitea/pull/31020) * This isn't actually a breaking chagne but they have improved docs around how to properly set Host and X-Forwarded-Proto headers for gitea to enable better logging behind a reverse proxy. We should investigate. * Remember log in for a month by default (https://github.com/go-gitea/gitea/pull/30150) * Default was a week. We should consider rolling back to low values since we don't have real users. * Breaking summary for template refactoring (https://github.com/go-gitea/gitea/pull/29395) * All custom templates need to follow these changes * I don't think we're using any of the changed methods/functions in our templates. Testing should help confirm this. * Recommend/convert to use case-sensitive collation for MySQL/MSSQL (https://github.com/go-gitea/gitea/pull/28662) * This is the doctor update to address case sensitivity problems between git and gitea. We'll need to test this as part of our upgrade process and testing. * Make offline mode as default to not connect external avatar service by default (https://github.com/go-gitea/gitea/pull/28548) * We are already disabling gravatar. I think this will disable it harder. * Include public repos in the doer's dashboard for issue search (https://github.com/go-gitea/gitea/pull/28304) * This affects end user dashboard info rendering which we don't use. * Use restricted sanitizer for repository description (https://github.com/go-gitea/gitea/pull/28141) * We already control what goes into repo descriptions via projects.yaml. Shouldn't really affect us. * Support storage base path as prefix (https://github.com/go-gitea/gitea/pull/27827) * This change looks scary at first glance but appears to only affect minio storage systems (which is like an s3 abstraction layer). We store things to disk and shouldn't be affected if I read the PR correctly. * Enhanced auth token / remember me (https://github.com/go-gitea/gitea/pull/27606) * THis appears to improve security but it isn't clear what the effect on end users is. We'll see if our CI jobs are happy with new token generation I guess. * Rename the default themes to gitea-light, gitea-dark, gitea-auto (https://github.com/go-gitea/gitea/pull/27419) * If you didn't see the new themes, please remove the [ui].THEMES config option from app.ini * We don't do anything special for themes so this should noop for us. * Require MySQL 8.0, PostgreSQL 12, MSSQL 2012 (https://github.com/go-gitea/gitea/pull/27337) * Our version of MariaDB should be new enough to rough rough feature equivalent with MySQL 8.0 and newer. We might consider helping upstream add MariaDB testing if they haven't already though. Change-Id: Ifb4f0d92d70bc06f717e6535f1b67a221e127180 --- docker/gitea/Dockerfile | 4 +- .../custom/templates/base/head_navbar.tmpl | 113 +++--- .../gitea/custom/templates/repo/header.tmpl | 370 +++++++++--------- playbooks/roles/gitea/templates/app.ini.j2 | 2 +- 4 files changed, 246 insertions(+), 243 deletions(-) diff --git a/docker/gitea/Dockerfile b/docker/gitea/Dockerfile index f0d69da5e3..03ed9fc098 100644 --- a/docker/gitea/Dockerfile +++ b/docker/gitea/Dockerfile @@ -25,14 +25,14 @@ ################################### # Build stage -FROM docker.io/library/golang:1.21-bookworm AS build-env +FROM docker.io/library/golang:1.22-bookworm AS build-env LABEL maintainer="infra-root@openstack.org" ARG GOPROXY ENV GOPROXY ${GOPROXY:-direct} -ARG GITEA_VERSION="v1.21.11" +ARG GITEA_VERSION="v1.22.1" ENV TAGS "bindata timetzdata $TAGS" # Build deps diff --git a/docker/gitea/custom/templates/base/head_navbar.tmpl b/docker/gitea/custom/templates/base/head_navbar.tmpl index c7cef0d6c6..5162356e5f 100644 --- a/docker/gitea/custom/templates/base/head_navbar.tmpl +++ b/docker/gitea/custom/templates/base/head_navbar.tmpl @@ -4,23 +4,31 @@ {{end}} diff --git a/docker/gitea/custom/templates/repo/header.tmpl b/docker/gitea/custom/templates/repo/header.tmpl index d69947241a..453ae4ab3a 100644 --- a/docker/gitea/custom/templates/repo/header.tmpl +++ b/docker/gitea/custom/templates/repo/header.tmpl @@ -1,39 +1,38 @@ -
+
{{with .Repository}}
-
-
-
- {{template "repo/icon" .}} +
+
+ {{template "repo/icon" .}} +
+
+ - {{.Owner.Name}} -
/
- {{.Name}} -
- {{if .IsArchived}} - {{ctx.Locale.Tr "repo.desc.archived"}} +
+
+ {{if .IsArchived}} + {{ctx.Locale.Tr "repo.desc.archived"}} +
{{svg "octicon-archive" 18}}
+ {{end}} + {{if .IsPrivate}} + {{ctx.Locale.Tr "repo.desc.private"}} +
{{svg "octicon-lock" 18}}
+ {{else}} + {{if .Owner.Visibility.IsPrivate}} + {{ctx.Locale.Tr "repo.desc.internal"}} +
{{svg "octicon-shield-lock" 18}}
{{end}} - {{if .IsPrivate}} - {{ctx.Locale.Tr "repo.desc.private"}} - {{else}} - {{if .Owner.Visibility.IsPrivate}} - {{ctx.Locale.Tr "repo.desc.internal"}} - {{end}} - {{end}} - {{if .IsTemplate}} - {{ctx.Locale.Tr "repo.desc.template"}} - {{end}} -
- {{if $.EnableFeed}} - {{svg "octicon-rss" 18}} + {{end}} + {{if .IsTemplate}} + {{ctx.Locale.Tr "repo.desc.template"}} +
{{svg "octicon-repo-template" 18}}
+ {{end}} + {{if eq .ObjectFormatName "sha256"}} + {{ctx.Locale.Tr "repo.desc.sha256"}} {{end}}
- {{if $.PullMirror}} -
{{ctx.Locale.Tr "repo.mirror_from"}} {{$.PullMirror.RemoteAddress}}
- {{end}} - {{if .IsFork}}
{{ctx.Locale.Tr "repo.forked_from"}} {{.BaseRepo.FullName}}
{{end}} - {{if .IsGenerated}}
{{ctx.Locale.Tr "repo.generated_from"}} {{.TemplateRepo.FullName}}
{{end}}
-
-
-{{end}} -
- {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}} - - {{else if .Permission.IsAdmin}} - + {{if $.PullMirror}} +
+ {{ctx.Locale.Tr "repo.mirror_from"}} + {{$.PullMirror.RemoteAddress}} + {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}}
{{end}} + {{if .IsFork}}
{{ctx.Locale.Tr "repo.forked_from"}} {{.BaseRepo.FullName}}
{{end}} + {{if .IsGenerated}}
{{ctx.Locale.Tr "repo.generated_from"}} {{(.TemplateRepo ctx).FullName}}
{{end}} +
+{{end}} +
+ + {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}} +
+ {{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}} + + {{svg "octicon-code"}} {{ctx.Locale.Tr "repo.code"}} + + {{end}} + + {{if .Permission.CanRead ctx.Consts.RepoUnitTypeIssues}} + + {{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues"}} + {{if .Repository.NumOpenIssues}} + {{CountFmt .Repository.NumOpenIssues}} + {{end}} + + {{end}} + + {{if .Permission.CanRead ctx.Consts.RepoUnitTypeExternalTracker}} + + {{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues"}} + + {{end}} + + {{if and .Repository.CanEnablePulls (.Permission.CanRead ctx.Consts.RepoUnitTypePullRequests)}} + + {{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.pulls"}} + {{if .Repository.NumOpenPulls}} + {{CountFmt .Repository.NumOpenPulls}} + {{end}} + + {{end}} + + {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}} + + {{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}} + {{if .Repository.NumOpenActionRuns}} + {{CountFmt .Repository.NumOpenActionRuns}} + {{end}} + + {{end}} + + + + {{svg "octicon-git-pull-request"}} Proposed changes + + + {{if .Permission.CanRead ctx.Consts.RepoUnitTypePackages}} + + {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}} + + {{end}} + + {{$projectsUnit := .Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypeProjects}} + {{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeProjects) ($projectsUnit.ProjectsConfig.IsProjectsAllowed "repo")}} + + {{svg "octicon-project"}} {{ctx.Locale.Tr "repo.project_board"}} + {{if .Repository.NumOpenProjects}} + {{CountFmt .Repository.NumOpenProjects}} + {{end}} + + {{end}} + + + + {{if .Permission.CanRead ctx.Consts.RepoUnitTypeWiki}} + + {{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}} + + {{end}} + + {{if .Permission.CanRead ctx.Consts.RepoUnitTypeExternalWiki}} + + {{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.wiki"}} + + {{end}} + + + + {{template "custom/extra_tabs" .}} + + {{if .Permission.IsAdmin}} + + + {{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}} + + {{end}} +
+ {{else if .Permission.IsAdmin}} + + {{end}} +
diff --git a/playbooks/roles/gitea/templates/app.ini.j2 b/playbooks/roles/gitea/templates/app.ini.j2 index ab69ebad52..213641ae2c 100644 --- a/playbooks/roles/gitea/templates/app.ini.j2 +++ b/playbooks/roles/gitea/templates/app.ini.j2 @@ -97,7 +97,7 @@ NO_REPLY_ADDRESS = noreply.example.org ENABLED = false [oauth2] -ENABLE = false +ENABLED = false ; TODO we don't do oauth2 do we need to set this value? JWT_SECRET = {{ gitea_oauth2_jwt_secret }} ; TODO we don't do oauth2 do we need to set this value?