summaryrefslogtreecommitdiffstats
path: root/routes/routes.go
diff options
context:
space:
mode:
Diffstat (limited to 'routes/routes.go')
-rw-r--r--routes/routes.go86
1 files changed, 68 insertions, 18 deletions
diff --git a/routes/routes.go b/routes/routes.go
index ca2e729..6c6df6c 100644
--- a/routes/routes.go
+++ b/routes/routes.go
@@ -159,12 +159,22 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {
return
}
name = filepath.Clean(name)
- path := filepath.Join(d.c.Repo.ScanPath, name)
+ path := d.c.Repo.ScanPath
+ category := flow.Param(r.Context(), "category")
+ if category != "" {
+ path = filepath.Join(path, category)
+ log.Println(category)
+ }
+ path = filepath.Join(path, name)
+ log.Println(path)
gr, err := git.Open(path, "")
if err != nil {
- d.Write404(w)
- return
+ gr, err = git.Open(path+".git", "")
+ if err != nil {
+ d.Write404(w)
+ return
+ }
}
commits, err := gr.Commits()
@@ -242,11 +252,19 @@ func (d *deps) RepoTree(w http.ResponseWriter, r *http.Request) {
ref := flow.Param(r.Context(), "ref")
name = filepath.Clean(name)
- path := filepath.Join(d.c.Repo.ScanPath, name)
+ path := d.c.Repo.ScanPath
+ category := flow.Param(r.Context(), "category")
+ if category != "" {
+ path = filepath.Join(path, category)
+ }
+ path = filepath.Join(path, name)
gr, err := git.Open(path, ref)
if err != nil {
- d.Write404(w)
- return
+ gr, err = git.Open(path+".git", ref)
+ if err != nil {
+ d.Write404(w)
+ return
+ }
}
files, err := gr.FileTree(treePath)
@@ -277,11 +295,19 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) {
ref := flow.Param(r.Context(), "ref")
name = filepath.Clean(name)
- path := filepath.Join(d.c.Repo.ScanPath, name)
+ path := d.c.Repo.ScanPath
+ category := flow.Param(r.Context(), "category")
+ if category != "" {
+ path = filepath.Join(path, category)
+ }
+ path = filepath.Join(path, name)
gr, err := git.Open(path, ref)
if err != nil {
- d.Write404(w)
- return
+ gr, err = git.Open(path+".git", ref)
+ if err != nil {
+ d.Write404(w)
+ return
+ }
}
contents, err := gr.FileContent(treePath)
@@ -303,11 +329,19 @@ func (d *deps) Log(w http.ResponseWriter, r *http.Request) {
}
ref := flow.Param(r.Context(), "ref")
- path := filepath.Join(d.c.Repo.ScanPath, name)
+ path := d.c.Repo.ScanPath
+ category := flow.Param(r.Context(), "category")
+ if category != "" {
+ path = filepath.Join(path, category)
+ }
+ path = filepath.Join(path, name)
gr, err := git.Open(path, ref)
if err != nil {
- d.Write404(w)
- return
+ gr, err = git.Open(path+".git", ref)
+ if err != nil {
+ d.Write404(w)
+ return
+ }
}
commits, err := gr.Commits()
@@ -342,11 +376,19 @@ func (d *deps) Diff(w http.ResponseWriter, r *http.Request) {
}
ref := flow.Param(r.Context(), "ref")
- path := filepath.Join(d.c.Repo.ScanPath, name)
+ path := d.c.Repo.ScanPath
+ category := flow.Param(r.Context(), "category")
+ if category != "" {
+ path = filepath.Join(path, category)
+ }
+ path = filepath.Join(path, name)
gr, err := git.Open(path, ref)
if err != nil {
- d.Write404(w)
- return
+ gr, err = git.Open(path+".git", ref)
+ if err != nil {
+ d.Write404(w)
+ return
+ }
}
diff, err := gr.Diff()
@@ -382,11 +424,19 @@ func (d *deps) Refs(w http.ResponseWriter, r *http.Request) {
return
}
- path := filepath.Join(d.c.Repo.ScanPath, name)
+ path := d.c.Repo.ScanPath
+ category := flow.Param(r.Context(), "category")
+ if category != "" {
+ path = filepath.Join(path, category)
+ }
+ path = filepath.Join(path, name)
gr, err := git.Open(path, "")
if err != nil {
- d.Write404(w)
- return
+ gr, err = git.Open(path+".git", "")
+ if err != nil {
+ d.Write404(w)
+ return
+ }
}
tags, err := gr.Tags()