2 files changed,
11 insertions(+),
1 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-02-06 20:55:59 +0200
Change ID:
zwvsnvxorvrtxnxmvzsoqvxuskovkwvy
Parent:
ebd4bbe
jump to
| M | internal/git/repo.go |
| M | internal/handlers/repo.go |
M
internal/git/repo.go
@@ -15,7 +15,10 @@ )
// Thanks https://git.icyphox.sh/legit/blob/master/git/git.go -var ErrEmptyRepo = errors.New("repository has no commits") +var ( + ErrEmptyRepo = errors.New("repository has no commits") + ErrFileNotFound = errors.New("file not found") +) type Repo struct { path string@@ -138,6 +141,9 @@ }
file, err := tree.File(path) if err != nil { + if errors.Is(err, object.ErrFileNotFound) { + return "", ErrFileNotFound + } return "", err }
M
internal/handlers/repo.go
@@ -181,6 +181,10 @@ }
contents, err := repo.FileContent(treePath) if err != nil { + if errors.Is(err, git.ErrFileNotFound) { + h.write404(w, err) + return + } h.write500(w, err) return }