all repos — gitxt @ 5b5fab934eef3b3957fe5d712672487e9234d0ce

Code collaboration for the small web

Fix route for tree view
James Mills 1290234+[email protected]
Thu, 29 Dec 2022 20:17:49 +1000
commit

5b5fab934eef3b3957fe5d712672487e9234d0ce

parent

2f572924460cb3bcc140cb1b30fab1619bad9b5a

2 files changed, 6 insertions(+), 7 deletions(-)

jump to
M internal/routes/handler.gointernal/routes/handler.go

@@ -18,6 +18,7 @@

mux.HandleFunc("/", d.Index) mux.HandleFunc("/:name", d.RepoIndex) mux.HandleFunc("/static/*path", d.ServeStatic) + mux.HandleFunc("/:name/tree/:ref", d.RepoTree) mux.HandleFunc("/:name/tree/:ref/*path", d.RepoTree) mux.HandleFunc("/:name/blob/:ref/*path", d.FileContent) mux.HandleFunc("/:name/log/:ref", d.Log)
M internal/routes/routes.gointernal/routes/routes.go

@@ -3,7 +3,6 @@

import ( "fmt" "html/template" - "log" "net/http" "os" "path/filepath"

@@ -15,6 +14,7 @@ "github.com/dustin/go-humanize"

"github.com/kataras/muxie" "github.com/microcosm-cc/bluemonday" "github.com/russross/blackfriday/v2" + log "github.com/sirupsen/logrus" "gitxt.net/gitxt/internal/config" "gitxt.net/gitxt/internal/git"

@@ -95,6 +95,7 @@ path := filepath.Join(d.c.Repo.ScanPath, name)

gr, err := git.Open(path, "") if err != nil { + log.WithError(err).Errorf("error opening repo at %s", path) d.Write404(w) return }

@@ -125,14 +126,10 @@ break

} } - if len(readmeContent) <= 0 { - log.Printf("no readme found for %s", name) - } - mainBranch, err := gr.FindMainBranch(d.c.Repo.MainBranch) if err != nil { + log.WithError(err).Errorf("error finding main branch for %s", path) d.Write500(w) - log.Println(err) return }

@@ -170,14 +167,15 @@ name = filepath.Clean(name)

path := filepath.Join(d.c.Repo.ScanPath, name) gr, err := git.Open(path, ref) if err != nil { + log.WithError(err).Errorf("error opening repo at %s", path) d.Write404(w) return } files, err := gr.FileTree(treePath) if err != nil { + log.WithError(err).Errorf("error getting file tree at %s", treePath) d.Write500(w) - log.Println(err) return }