mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
[GITEA] allow viewing the latest Action Run on the web
Similar to how some other parts of the web UI support a `/latest` path to directly go to the latest of a certain thing, let the Actions web UI do the same: `/{owner}/{repo}/actions/runs/latest` will redirect to the latest run, if there's one available. Fixes gitea#27991. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commitf67ccef1dd
) Code cleanup in the actions.ViewLatest route handler Based on feedback received after the feature was merged, use `ctx.NotFound` and `ctx.ServerError`, and drop the use of the unnecessary `ctx.Written()`. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu> (cherry picked from commit74e42da563
) (cherry picked from commitf7535a1cef
) (cherry picked from commit1a90cd37c3
) (cherry picked from commitd86d71340a
) (cherry picked from commit9e5cce1afc
) (cherry picked from commit2013fb3fab
) (cherry picked from commit88b9d21d11
) (cherry picked from commit72c020298e
) (cherry picked from commit6525f730df
)
This commit is contained in:
parent
533c87da65
commit
fa0759962b
4 changed files with 130 additions and 11 deletions
|
@ -312,6 +312,17 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
|
|||
return commiter.Commit()
|
||||
}
|
||||
|
||||
func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
|
||||
var run ActionRun
|
||||
has, err := db.GetEngine(ctx).Where("repo_id=?", repoID).OrderBy("id DESC").Limit(1).Get(&run)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, fmt.Errorf("latest run: %w", util.ErrNotExist)
|
||||
}
|
||||
return &run, nil
|
||||
}
|
||||
|
||||
func GetRunByID(ctx context.Context, id int64) (*ActionRun, error) {
|
||||
var run ActionRun
|
||||
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&run)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue