Fix route for tree view
James Mills 1290234+[email protected]
Thu, 29 Dec 2022 20:17:49 +1000
2 files changed,
6 insertions(+),
7 deletions(-)
M
internal/routes/handler.go
→
internal/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.go
→
internal/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 }