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 @@ +