Skip to content

Commit 22fec16

Browse files
authored
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)
1 parent 6840258 commit 22fec16

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

routers/web/repo/actions/view.go

+42
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/models/db"
1515
"code.gitea.io/gitea/models/unit"
1616
"code.gitea.io/gitea/modules/actions"
17+
"code.gitea.io/gitea/modules/base"
1718
context_module "code.gitea.io/gitea/modules/context"
1819
"code.gitea.io/gitea/modules/log"
1920
"code.gitea.io/gitea/modules/timeutil"
@@ -57,6 +58,7 @@ type ViewResponse struct {
5758
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
5859
Done bool `json:"done"`
5960
Jobs []*ViewJob `json:"jobs"`
61+
Commit ViewCommit `json:"commit"`
6062
} `json:"run"`
6163
CurrentJob struct {
6264
Title string `json:"title"`
@@ -76,6 +78,25 @@ type ViewJob struct {
7678
CanRerun bool `json:"canRerun"`
7779
}
7880

81+
type ViewCommit struct {
82+
LocaleCommit string `json:"localeCommit"`
83+
LocalePushedBy string `json:"localePushedBy"`
84+
ShortSha string `json:"shortSHA"`
85+
Link string `json:"link"`
86+
Pusher ViewUser `json:"pusher"`
87+
Branch ViewBranch `json:"branch"`
88+
}
89+
90+
type ViewUser struct {
91+
DisplayName string `json:"displayName"`
92+
Link string `json:"link"`
93+
}
94+
95+
type ViewBranch struct {
96+
Name string `json:"name"`
97+
Link string `json:"link"`
98+
}
99+
79100
type ViewJobStep struct {
80101
Summary string `json:"summary"`
81102
Duration string `json:"duration"`
@@ -104,6 +125,10 @@ func ViewPost(ctx *context_module.Context) {
104125
return
105126
}
106127
run := current.Run
128+
if err := run.LoadAttributes(ctx); err != nil {
129+
ctx.Error(http.StatusInternalServerError, err.Error())
130+
return
131+
}
107132

108133
resp := &ViewResponse{}
109134

@@ -123,6 +148,23 @@ func ViewPost(ctx *context_module.Context) {
123148
})
124149
}
125150

151+
pusher := ViewUser{
152+
DisplayName: run.TriggerUser.GetDisplayName(),
153+
Link: run.TriggerUser.HomeLink(),
154+
}
155+
branch := ViewBranch{
156+
Name: run.PrettyRef(),
157+
Link: run.RefLink(),
158+
}
159+
resp.State.Run.Commit = ViewCommit{
160+
LocaleCommit: ctx.Tr("actions.runs.commit"),
161+
LocalePushedBy: ctx.Tr("actions.runs.pushed_by"),
162+
ShortSha: base.ShortSha(run.CommitSHA),
163+
Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
164+
Pusher: pusher,
165+
Branch: branch,
166+
}
167+
126168
var task *actions_model.ActionTask
127169
if current.TaskID > 0 {
128170
var err error

web_src/js/components/RepoActionView.vue

+27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
<i class="stop circle outline icon"/>
1414
</button>
1515
</div>
16+
<div class="action-commit-summary">
17+
{{ run.commit.localeCommit }}
18+
<a :href="run.commit.link">{{ run.commit.shortSHA }}</a>
19+
&nbsp;<span class="ui label">
20+
<a :href="run.commit.branch.link">{{ run.commit.branch.name }}</a>
21+
</span>
22+
&nbsp;{{ run.commit.localePushedBy }}
23+
<a :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
24+
</div>
1625
</div>
1726
<div class="action-view-body">
1827
<div class="action-view-left">
@@ -105,6 +114,20 @@ const sfc = {
105114
// canRerun: false,
106115
// },
107116
],
117+
commit: {
118+
localeCommit: '',
119+
localePushedBy: '',
120+
shortSHA: '',
121+
link: '',
122+
pusher: {
123+
displayName: '',
124+
link: '',
125+
},
126+
branch: {
127+
name: '',
128+
link: '',
129+
},
130+
}
108131
},
109132
currentJob: {
110133
title: '',
@@ -332,6 +355,10 @@ export function initRepositoryActionView() {
332355
padding: 0 5px;
333356
}
334357
358+
.action-commit-summary {
359+
padding: 10px 10px;
360+
}
361+
335362
/* ================ */
336363
/* action view left */
337364

0 commit comments

Comments
 (0)