all repos

mugit @ e6fe8220d1822f3b98bb22da5ef766ed759309d0

馃惍 git server that your cow will love
2 files changed, 11 insertions(+), 1 deletions(-)
fix: 404 on file not found
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-02-06 20:55:59 +0200
Authored at: 2026-02-05 23:38:37 +0200
Change ID: zwvsnvxorvrtxnxmvzsoqvxuskovkwvy
Parent: ebd4bbe
M internal/git/repo.go
路路路
        15
        15
         

      
        16
        16
         // Thanks https://git.icyphox.sh/legit/blob/master/git/git.go

      
        17
        17
         

      
        18
        
        -var ErrEmptyRepo = errors.New("repository has no commits")

      
        
        18
        +var (

      
        
        19
        +	ErrEmptyRepo    = errors.New("repository has no commits")

      
        
        20
        +	ErrFileNotFound = errors.New("file not found")

      
        
        21
        +)

      
        19
        22
         

      
        20
        23
         type Repo struct {

      
        21
        24
         	path string

      路路路
        138
        141
         

      
        139
        142
         	file, err := tree.File(path)

      
        140
        143
         	if err != nil {

      
        
        144
        +		if errors.Is(err, object.ErrFileNotFound) {

      
        
        145
        +			return "", ErrFileNotFound

      
        
        146
        +		}

      
        141
        147
         		return "", err

      
        142
        148
         	}

      
        143
        149
         

      
M internal/handlers/repo.go
路路路
        181
        181
         

      
        182
        182
         	contents, err := repo.FileContent(treePath)

      
        183
        183
         	if err != nil {

      
        
        184
        +		if errors.Is(err, git.ErrFileNotFound) {

      
        
        185
        +			h.write404(w, err)

      
        
        186
        +			return

      
        
        187
        +		}

      
        184
        188
         		h.write500(w, err)

      
        185
        189
         		return

      
        186
        190
         	}