From 91516c2c30c65ad2f6b4c05adc52b4b782d449b0 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Wed, 1 Mar 2023 07:15:06 +0000 Subject: [PATCH 1/3] add commit info --- routers/web/repo/actions/view.go | 39 ++++++++++++++++++++++++ web_src/js/components/RepoActionView.vue | 27 ++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index dd2750f905883..7396b5351b1b9 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/actions" + "code.gitea.io/gitea/modules/base" context_module "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" @@ -55,6 +56,7 @@ type ViewResponse struct { CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve Done bool `json:"done"` Jobs []*ViewJob `json:"jobs"` + Commit ViewCommit `json:"commit"` } `json:"run"` CurrentJob struct { Title string `json:"title"` @@ -74,6 +76,25 @@ type ViewJob struct { CanRerun bool `json:"canRerun"` } +type ViewCommit struct { + LocaleCommit string `json:"localeCommit"` + LocalePushedBy string `json:"localePushedBy"` + ShortSha string `json:"shortSHA"` + Link string `json:"link"` + Pusher ViewUser `json:"pusher"` + Branch ViewBranch `json:"branch"` +} + +type ViewUser struct { + DisplayName string `json:"displayName"` + Link string `json:"link"` +} + +type ViewBranch struct { + Name string `json:"name"` + Link string `json:"link"` +} + type ViewJobStep struct { Summary string `json:"summary"` Duration string `json:"duration"` @@ -102,6 +123,7 @@ func ViewPost(ctx *context_module.Context) { return } run := current.Run + run.LoadAttributes(ctx) resp := &ViewResponse{} @@ -120,6 +142,23 @@ func ViewPost(ctx *context_module.Context) { }) } + pusher := ViewUser{ + DisplayName: run.TriggerUser.GetDisplayName(), + Link: run.TriggerUser.HomeLink(), + } + branch := ViewBranch{ + Name: run.PrettyRef(), + Link: run.RefLink(), + } + resp.State.Run.Commit = ViewCommit{ + LocaleCommit: ctx.Tr("actions.runs.commit"), + LocalePushedBy: ctx.Tr("actions.runs.pushed_by"), + ShortSha: base.ShortSha(run.CommitSHA), + Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA), + Pusher: pusher, + Branch: branch, + } + var task *actions_model.ActionTask if current.TaskID > 0 { var err error diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index 762067f52388b..b0081bc983a99 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -10,6 +10,15 @@ +
+ {{run.commit.localeCommit}} + {{run.commit.shortSHA}} +   + {{run.commit.branch.name}} + +  {{run.commit.localePushedBy}} + {{run.commit.pusher.displayName}} +
@@ -110,6 +119,20 @@ const sfc = { // canRerun: false, // }, ], + commit: { + localeCommit: '', + localePushedBy: '', + shortSHA: '', + link: '', + pusher: { + displayName: '', + link: '', + }, + branch: { + name: '', + link: '', + }, + } }, currentJob: { title: '', @@ -330,6 +353,10 @@ export function initRepositoryActionView() { padding: 0 10px; } +.action-commit-summary { + padding: 10px 10px; +} + // ================ // action view left From b45e9626de5ee534aa9cb4be6c272c1d77320c02 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Wed, 1 Mar 2023 07:34:21 +0000 Subject: [PATCH 2/3] fix lint --- web_src/js/components/RepoActionView.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue index b0081bc983a99..96ccda6975535 100644 --- a/web_src/js/components/RepoActionView.vue +++ b/web_src/js/components/RepoActionView.vue @@ -11,13 +11,13 @@
- {{run.commit.localeCommit}} - {{run.commit.shortSHA}} + {{ run.commit.localeCommit }} + {{ run.commit.shortSHA }}   - {{run.commit.branch.name}} + {{ run.commit.branch.name }} -  {{run.commit.localePushedBy}} - {{run.commit.pusher.displayName}} +  {{ run.commit.localePushedBy }} + {{ run.commit.pusher.displayName }}
From d3d4fec1787a6e31542592868774f6fb8828575c Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Wed, 1 Mar 2023 07:44:20 +0000 Subject: [PATCH 3/3] fix --- routers/web/repo/actions/view.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 7396b5351b1b9..6cb9036498452 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -123,7 +123,10 @@ func ViewPost(ctx *context_module.Context) { return } run := current.Run - run.LoadAttributes(ctx) + if err := run.LoadAttributes(ctx); err != nil { + ctx.Error(http.StatusInternalServerError, err.Error()) + return + } resp := &ViewResponse{}