all repos

mugit @ b883855e4eda3fc98a0e13cf746be4fce83ccc81

馃惍 git server that your cow will love
1 files changed, 8 insertions(+), 7 deletions(-)
fix: check if ref exists before archiving
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-02-24 17:51:49 +0200
Authored at: 2026-02-24 17:51:02 +0200
Change ID: kokmnqxprrxzzxktkozzvzksxrvpvxmu
Parent: 88da23a
M internal/handlers/git.go
路路路
        32
        32
         }

      
        33
        33
         

      
        34
        34
         func (h *handlers) infoRefs(w http.ResponseWriter, r *http.Request) {

      
        35
        
        -	path, err := h.checkRepoPublicityAndGetPath(r.PathValue("name"))

      
        
        35
        +	path, err := h.checkRepoPublicityAndGetPath(r.PathValue("name"), "")

      
        36
        36
         	if err != nil {

      
        37
        37
         		h.write404(w, err)

      
        38
        38
         		return

      路路路
        48
        48
         }

      
        49
        49
         

      
        50
        50
         func (h *handlers) uploadPack(w http.ResponseWriter, r *http.Request) {

      
        51
        
        -	path, err := h.checkRepoPublicityAndGetPath(r.PathValue("name"))

      
        
        51
        +	path, err := h.checkRepoPublicityAndGetPath(r.PathValue("name"), "")

      
        52
        52
         	if err != nil {

      
        53
        53
         		h.write404(w, err)

      
        54
        54
         		return

      路路路
        65
        65
         }

      
        66
        66
         

      
        67
        67
         func (h *handlers) archiveHandler(w http.ResponseWriter, r *http.Request) {

      
        68
        
        -	ref := h.parseRef(r.PathValue("ref"))

      
        69
        68
         	name := r.PathValue("name")

      
        70
        
        -	path, err := h.checkRepoPublicityAndGetPath(name)

      
        
        69
        +	ref := h.parseRef(r.PathValue("ref"))

      
        
        70
        +

      
        
        71
        +	path, err := h.checkRepoPublicityAndGetPath(name, ref)

      
        71
        72
         	if err != nil {

      
        72
        73
         		h.write404(w, err)

      
        73
        74
         		return

      路路路
        84
        85
         	}

      
        85
        86
         }

      
        86
        87
         

      
        87
        
        -func (h *handlers) checkRepoPublicityAndGetPath(name string) (string, error) {

      
        
        88
        +func (h *handlers) checkRepoPublicityAndGetPath(name string, ref string) (string, error) {

      
        88
        89
         	name = git.ResolveName(name)

      
        89
        90
         	path, err := git.ResolvePath(h.c.Repo.Dir, name)

      
        90
        91
         	if err != nil {

      
        91
        92
         		return "", err

      
        92
        93
         	}

      
        93
        94
         

      
        94
        
        -	if _, err := git.OpenPublic(path, ""); err != nil {

      
        95
        
        -		return "", err

      
        
        95
        +	if _, oerr := git.OpenPublic(path, ref); oerr != nil {

      
        
        96
        +		return "", oerr

      
        96
        97
         	}

      
        97
        98
         

      
        98
        99
         	return path, err