all repos — elgit @ cfea2a3ba078b13b46a99963953175f6d1c16ff1

fork of legit: web frontend for git, written in go

address linter complaints

Alan Pearce
commit

cfea2a3ba078b13b46a99963953175f6d1c16ff1

parent

6c5cc57b578117ef8d56432f3e8b114cb39b5aee

4 files changed, 12 insertions(+), 12 deletions(-)

changed files
M git/service/service.gogit/service/service.go
@@ -18,13 +18,13 @@ const timeout = 1 * time.Minute
// Mostly from charmbracelet/soft-serve and sosedoff/gitkit. -type ServiceCommand struct { +type Command struct { Dir string Stdin io.Reader Stdout http.ResponseWriter } -func (c *ServiceCommand) InfoRefs(ctx context.Context) error { +func (c *Command) InfoRefs(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() cmd := exec.CommandContext(ctx, "git", []string{
@@ -79,7 +79,7 @@
return nil } -func (c *ServiceCommand) UploadPack(ctx context.Context) (err error) { +func (c *Command) UploadPack(ctx context.Context) (err error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() cmd := exec.CommandContext(ctx, "git", []string{
M routes/git.goroutes/git.go
@@ -24,7 +24,7 @@ w.Header().Set("content-type", "application/x-git-upload-pack-advertisement")
w.Header().Set("cache-control", "no-cache") w.WriteHeader(http.StatusOK) - cmd := service.ServiceCommand{ + cmd := service.Command{ Dir: repo, Stdout: w, }
@@ -54,7 +54,7 @@ w.Header().Set("Transfer-Encoding", "chunked")
w.Header().Set("cache-control", "no-cache") w.WriteHeader(http.StatusOK) - cmd := service.ServiceCommand{ + cmd := service.Command{ Dir: repo, Stdout: w, }
M routes/handler.goroutes/handler.go
@@ -44,13 +44,14 @@
return } - if rest == "info/refs" && + switch { + case rest == "info/refs" && r.URL.RawQuery == "service=git-upload-pack" && - r.Method == "GET" { + r.Method == "GET": d.InfoRefs(w, r, params) - } else if rest == "git-upload-pack" && r.Method == "POST" { + case rest == "git-upload-pack" && r.Method == "POST": d.UploadPack(w, r, params) - } else if r.Method == "GET" { + case r.Method == "GET": if fixed, found := strings.CutSuffix(r.URL.Path, "/"); found { http.Redirect(w, r, fixed, http.StatusPermanentRedirect) } else {
M unveil_stub.gounveil_stub.go
@@ -1,11 +1,10 @@
//go:build !openbsd -// +build !openbsd // Stub functions for GOOS that don't support unix.Unveil() package main -func Unveil(path string, perms string) error { +func Unveil(_ string, _ string) error { return nil }
@@ -13,6 +12,6 @@ func UnveilBlock() error {
return nil } -func UnveilPaths(paths []string, perms string) error { +func UnveilPaths(_ []string, _ string) error { return nil }