aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-03-27 19:34:09 +0900
committerGitHub <noreply@github.com>2023-03-27 18:34:09 +0800
commit22fec1650a01ad85c80381f07d3f9c5ed5216da9 (patch)
tree841bef1bce4b6af76d00d5169eba771cb628ad7d
parent6840258c9593c0b8ffaf88af0e239d03ed2314d2 (diff)
downloadgitea-22fec1650a01ad85c80381f07d3f9c5ed5216da9.tar.gz
gitea-22fec1650a01ad85c80381f07d3f9c5ed5216da9.zip
Add commit info in action page (#23210)
Add more commit info in action detail page. ![image](https://user-images.githubusercontent.com/18380374/222069905-a5ab28b1-1cea-4eec-b3b9-f1c74145cb82.png)
-rw-r--r--routers/web/repo/actions/view.go42
-rw-r--r--web_src/js/components/RepoActionView.vue27
2 files changed, 69 insertions, 0 deletions
diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go
index 35b99d577d..0fa255b7e6 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/log"
"code.gitea.io/gitea/modules/timeutil"
@@ -57,6 +58,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"`
@@ -76,6 +78,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"`
@@ -104,6 +125,10 @@ func ViewPost(ctx *context_module.Context) {
return
}
run := current.Run
+ if err := run.LoadAttributes(ctx); err != nil {
+ ctx.Error(http.StatusInternalServerError, err.Error())
+ return
+ }
resp := &ViewResponse{}
@@ -123,6 +148,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 079c81921e..72801725d0 100644
--- a/web_src/js/components/RepoActionView.vue
+++ b/web_src/js/components/RepoActionView.vue
@@ -13,6 +13,15 @@
<i class="stop circle outline icon"/>
</button>
</div>
+ <div class="action-commit-summary">
+ {{ run.commit.localeCommit }}
+ <a :href="run.commit.link">{{ run.commit.shortSHA }}</a>
+ &nbsp;<span class="ui label">
+ <a :href="run.commit.branch.link">{{ run.commit.branch.name }}</a>
+ </span>
+ &nbsp;{{ run.commit.localePushedBy }}
+ <a :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
+ </div>
</div>
<div class="action-view-body">
<div class="action-view-left">
@@ -105,6 +114,20 @@ const sfc = {
// canRerun: false,
// },
],
+ commit: {
+ localeCommit: '',
+ localePushedBy: '',
+ shortSHA: '',
+ link: '',
+ pusher: {
+ displayName: '',
+ link: '',
+ },
+ branch: {
+ name: '',
+ link: '',
+ },
+ }
},
currentJob: {
title: '',
@@ -332,6 +355,10 @@ export function initRepositoryActionView() {
padding: 0 5px;
}
+.action-commit-summary {
+ padding: 10px 10px;
+}
+
/* ================ */
/* action view left */