mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-27 04:07:08 +00:00
[BUG] Fix panic on too high page number
- Fixes a panic where the file history router would panic if the page number was set to a page where no commits would be returned. It now returns a 404 in such case. - Regresion ofa5b1c1b0b3
- Panic log provided by @algernon. - Minimal integration test added. (cherry picked from commit6a49e3f468
) Co-authored-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
1f9c3040dc
commit
2eac7b1402
2 changed files with 24 additions and 0 deletions
|
@ -244,6 +244,12 @@ func FileHistory(ctx *context.Context) {
|
|||
ctx.ServerError("CommitsByFileAndRange", err)
|
||||
return
|
||||
}
|
||||
|
||||
if len(commits) == 0 {
|
||||
ctx.NotFound("CommitsByFileAndRange", nil)
|
||||
return
|
||||
}
|
||||
|
||||
oldestCommit := commits[len(commits)-1]
|
||||
|
||||
renamedFiles, err := git.GetCommitFileRenames(ctx, ctx.Repo.GitRepo.Path, oldestCommit.ID.String())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue