@@ -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+
79100type 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
0 commit comments