@@ -14,6 +14,7 @@ import (
14
14
"code.gitea.io/gitea/models/db"
15
15
"code.gitea.io/gitea/models/unit"
16
16
"code.gitea.io/gitea/modules/actions"
17
+ "code.gitea.io/gitea/modules/base"
17
18
context_module "code.gitea.io/gitea/modules/context"
18
19
"code.gitea.io/gitea/modules/log"
19
20
"code.gitea.io/gitea/modules/timeutil"
@@ -57,6 +58,7 @@ type ViewResponse struct {
57
58
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
58
59
Done bool `json:"done"`
59
60
Jobs []* ViewJob `json:"jobs"`
61
+ Commit ViewCommit `json:"commit"`
60
62
} `json:"run"`
61
63
CurrentJob struct {
62
64
Title string `json:"title"`
@@ -76,6 +78,25 @@ type ViewJob struct {
76
78
CanRerun bool `json:"canRerun"`
77
79
}
78
80
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
+
79
100
type ViewJobStep struct {
80
101
Summary string `json:"summary"`
81
102
Duration string `json:"duration"`
@@ -104,6 +125,10 @@ func ViewPost(ctx *context_module.Context) {
104
125
return
105
126
}
106
127
run := current .Run
128
+ if err := run .LoadAttributes (ctx ); err != nil {
129
+ ctx .Error (http .StatusInternalServerError , err .Error ())
130
+ return
131
+ }
107
132
108
133
resp := & ViewResponse {}
109
134
@@ -123,6 +148,23 @@ func ViewPost(ctx *context_module.Context) {
123
148
})
124
149
}
125
150
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
+
126
168
var task * actions_model.ActionTask
127
169
if current .TaskID > 0 {
128
170
var err error
0 commit comments