diff --git a/models/actions/run.go b/models/actions/run.go index d51bba65ec..1925a6493a 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -51,9 +51,19 @@ func init() { } func (run *ActionRun) HTMLURL() string { + if run.Repo == nil { + return "" + } return fmt.Sprintf("%s/actions/runs/%d", run.Repo.HTMLURL(), run.Index) } +func (run *ActionRun) Link() string { + if run.Repo == nil { + return "" + } + return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index) +} + // LoadAttributes load Repo TriggerUser if not loaded func (run *ActionRun) LoadAttributes(ctx context.Context) error { if run == nil { diff --git a/models/actions/task.go b/models/actions/task.go index 7253d8796b..19d728f5f4 100644 --- a/models/actions/task.go +++ b/models/actions/task.go @@ -7,7 +7,6 @@ import ( "context" "crypto/subtle" "fmt" - "strconv" "time" auth_model "code.gitea.io/gitea/models/auth" @@ -83,40 +82,18 @@ func (task *ActionTask) IsStopped() bool { return task.Stopped > 0 } -func (task *ActionTask) GetCommitSHA() string { - if task.Job == nil { +func (task *ActionTask) GetRunLink() string { + if task.Job == nil || task.Job.Run == nil { return "" } - if task.Job.Run == nil { - return "" - } - - return task.Job.Run.CommitSHA -} - -func (task *ActionTask) GetCommitSHAShort() string { - commitSHA := task.GetCommitSHA() - if len(commitSHA) > 8 { - return commitSHA[:8] - } - return commitSHA -} - -func (task *ActionTask) GetBuildViewLink() string { - if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { - return "" - } - return task.Job.Run.Repo.Link() + "/actions/runs/" + strconv.FormatInt(task.ID, 10) + return task.Job.Run.Link() } func (task *ActionTask) GetCommitLink() string { if task.Job == nil || task.Job.Run == nil || task.Job.Run.Repo == nil { return "" } - if commitSHA := task.GetCommitSHA(); commitSHA != "" { - return task.Job.Run.Repo.CommitLink(commitSHA) - } - return "" + return task.Job.Run.Repo.CommitLink(task.CommitSHA) } func (task *ActionTask) GetRepoName() string { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0636ffc341..3d057840d4 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3264,7 +3264,7 @@ runners.custom_labels = Custom Labels runners.custom_labels_helper = Custom labels are labels that are added manually by an administrator. A comma separates labels, whitespace at the start and end of each label are ignored. runners.runner_title = Runner runners.task_list = Recent tasks on this runner -runners.task_list.job = Job +runners.task_list.run = Run runners.task_list.status = Status runners.task_list.repository = Repository runners.task_list.commit = Commit diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index 9f40425e55..2e2e037de0 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -12,7 +12,7 @@
{{.locale.Tr "actions.runners.task_list.job"}} | +{{.locale.Tr "actions.runners.task_list.run"}} | {{.locale.Tr "actions.runners.task_list.status"}} | {{.locale.Tr "actions.runners.task_list.repository"}} | {{.locale.Tr "actions.runners.task_list.commit"}} | @@ -69,12 +69,12 @@|||
---|---|---|---|---|---|---|---|
{{template "shared/actions/runner_id" .ID}} | +{{template "shared/actions/runner_id" .ID}} | {{.Status.LocaleString $.locale}} | -{{.GetRepoName}} | -- {{.GetCommitSHAShort}} - | +{{.GetRepoName}} | ++ {{ShortSha .CommitSHA}} + | {{if .IsStopped}} {{TimeSinceUnix .Stopped $.locale}} {{else}}-{{end}} |