From b811574d479d7047f197cc5da27f9ba0bc55e88b Mon Sep 17 00:00:00 2001 From: metiftikci Date: Sun, 8 Dec 2024 06:23:09 +0300 Subject: [PATCH] fix: render job title as commit message (#32748) resolves #32724 --------- Co-authored-by: wxiaoguang (cherry picked from commit ad994780af48e2aff27b0e7e496fd559dc0fe3fc) Conflicts: routers/web/repo/actions/view.go because of RenderCommitMessage context --- routers/web/repo/actions/view.go | 26 +++++++++++++++--------- web_src/js/components/RepoActionView.vue | 6 +++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index e7dbb6d975..cab37acdd1 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -10,6 +10,7 @@ import ( "context" "errors" "fmt" + "html/template" "io" "net/http" "net/url" @@ -25,6 +26,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" + "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" @@ -108,16 +110,17 @@ type ViewRequest struct { type ViewResponse struct { State struct { Run struct { - Link string `json:"link"` - Title string `json:"title"` - Status string `json:"status"` - CanCancel bool `json:"canCancel"` - CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve - CanRerun bool `json:"canRerun"` - CanDeleteArtifact bool `json:"canDeleteArtifact"` - Done bool `json:"done"` - Jobs []*ViewJob `json:"jobs"` - Commit ViewCommit `json:"commit"` + Link string `json:"link"` + Title string `json:"title"` + TitleHTML template.HTML `json:"titleHTML"` + Status string `json:"status"` + CanCancel bool `json:"canCancel"` + CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve + CanRerun bool `json:"canRerun"` + CanDeleteArtifact bool `json:"canDeleteArtifact"` + Done bool `json:"done"` + Jobs []*ViewJob `json:"jobs"` + Commit ViewCommit `json:"commit"` } `json:"run"` CurrentJob struct { Title string `json:"title"` @@ -194,7 +197,10 @@ func ViewPost(ctx *context_module.Context) { resp := &ViewResponse{} + metas := ctx.Repo.Repository.ComposeMetas(ctx) + resp.State.Run.Title = run.Title + resp.State.Run.TitleHTML = templates.RenderCommitMessage(ctx, run.Title, metas) resp.State.Run.Link = run.Link() resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions) resp.State.Run.CanApprove = run.NeedApproval && ctx.Repo.CanWrite(unit.TypeActions) diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index b96d1f7573..941440c6f3 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -42,6 +42,7 @@ const sfc = { run: { link: '', title: '', + titleHTML: '', status: '', canCancel: false, canApprove: false, @@ -424,9 +425,8 @@ export function initRepositoryActionView() {
-

- {{ run.title }} -

+ +