Skip to content

Commit ad99478

Browse files
fix: render job title as commit message (#32748)
resolves #32724 --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent 1518f4e commit ad99478

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

Diff for: routers/web/repo/actions/view.go

+19-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"context"
1010
"errors"
1111
"fmt"
12+
"html/template"
1213
"io"
1314
"net/http"
1415
"net/url"
@@ -29,6 +30,7 @@ import (
2930
"code.gitea.io/gitea/modules/setting"
3031
"code.gitea.io/gitea/modules/storage"
3132
api "code.gitea.io/gitea/modules/structs"
33+
"code.gitea.io/gitea/modules/templates"
3234
"code.gitea.io/gitea/modules/timeutil"
3335
"code.gitea.io/gitea/modules/util"
3436
"code.gitea.io/gitea/modules/web"
@@ -87,19 +89,20 @@ type ViewResponse struct {
8789

8890
State struct {
8991
Run struct {
90-
Link string `json:"link"`
91-
Title string `json:"title"`
92-
Status string `json:"status"`
93-
CanCancel bool `json:"canCancel"`
94-
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
95-
CanRerun bool `json:"canRerun"`
96-
CanDeleteArtifact bool `json:"canDeleteArtifact"`
97-
Done bool `json:"done"`
98-
WorkflowID string `json:"workflowID"`
99-
WorkflowLink string `json:"workflowLink"`
100-
IsSchedule bool `json:"isSchedule"`
101-
Jobs []*ViewJob `json:"jobs"`
102-
Commit ViewCommit `json:"commit"`
92+
Link string `json:"link"`
93+
Title string `json:"title"`
94+
TitleHTML template.HTML `json:"titleHTML"`
95+
Status string `json:"status"`
96+
CanCancel bool `json:"canCancel"`
97+
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
98+
CanRerun bool `json:"canRerun"`
99+
CanDeleteArtifact bool `json:"canDeleteArtifact"`
100+
Done bool `json:"done"`
101+
WorkflowID string `json:"workflowID"`
102+
WorkflowLink string `json:"workflowLink"`
103+
IsSchedule bool `json:"isSchedule"`
104+
Jobs []*ViewJob `json:"jobs"`
105+
Commit ViewCommit `json:"commit"`
103106
} `json:"run"`
104107
CurrentJob struct {
105108
Title string `json:"title"`
@@ -200,7 +203,10 @@ func ViewPost(ctx *context_module.Context) {
200203
}
201204
}
202205

206+
metas := ctx.Repo.Repository.ComposeMetas(ctx)
207+
203208
resp.State.Run.Title = run.Title
209+
resp.State.Run.TitleHTML = templates.NewRenderUtils(ctx).RenderCommitMessage(run.Title, metas)
204210
resp.State.Run.Link = run.Link()
205211
resp.State.Run.CanCancel = !run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
206212
resp.State.Run.CanApprove = run.NeedApproval && ctx.Repo.CanWrite(unit.TypeActions)

Diff for: web_src/js/components/RepoActionView.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const sfc = {
5151
run: {
5252
link: '',
5353
title: '',
54+
titleHTML: '',
5455
status: '',
5556
canCancel: false,
5657
canApprove: false,
@@ -383,9 +384,8 @@ export function initRepositoryActionView() {
383384
<div class="action-info-summary">
384385
<div class="action-info-summary-title">
385386
<ActionRunStatus :locale-status="locale.status[run.status]" :status="run.status" :size="20"/>
386-
<h2 class="action-info-summary-title-text">
387-
{{ run.title }}
388-
</h2>
387+
<!-- eslint-disable-next-line vue/no-v-html -->
388+
<h2 class="action-info-summary-title-text" v-html="run.titleHTML"/>
389389
</div>
390390
<button class="ui basic small compact button primary" @click="approveRun()" v-if="run.canApprove">
391391
{{ locale.approve }}

0 commit comments

Comments
 (0)