summaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorLibravatar Derek Stevens <nilix@nilfm.cc>2023-01-31 21:30:40 -0700
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2023-02-05 15:12:02 +0530
commitde046690c01cf90c906ee74b8180d10f17757fb7 (patch)
tree5e4294489f6b8c1883816a5c9275c2dd35adca65 /routes
parent3060c752f8bbc4852939ee7f15732e9752d0c6ec (diff)
downloadlegit-de046690c01cf90c906ee74b8180d10f17757fb7.tar.gz
legit-de046690c01cf90c906ee74b8180d10f17757fb7.tar.bz2
legit-de046690c01cf90c906ee74b8180d10f17757fb7.zip
only add go meta import tag if go.mod exists in repo root
This is a multipart message in MIME format. Pretty self-explanitory :3 Signed-off-by: Derek Stevens <nilix@nilfm.cc>
Diffstat (limited to 'routes')
-rw-r--r--routes/routes.go1
-rw-r--r--routes/util.go7
2 files changed, 8 insertions, 0 deletions
diff --git a/routes/routes.go b/routes/routes.go
index 3124d1b..4d99ab0 100644
--- a/routes/routes.go
+++ b/routes/routes.go
@@ -151,6 +151,7 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {
data["commits"] = commits
data["desc"] = getDescription(path)
data["servername"] = d.c.Server.Name
+ data["gomod"] = isGoModule(gr)
if err := t.ExecuteTemplate(w, "repo", data); err != nil {
log.Println(err)
diff --git a/routes/util.go b/routes/util.go
index d3f80fe..e6a6267 100644
--- a/routes/util.go
+++ b/routes/util.go
@@ -3,8 +3,15 @@ package routes
import (
"os"
"path/filepath"
+
+ "git.icyphox.sh/legit/git"
)
+func isGoModule(gr *git.GitRepo) bool {
+ _, err := gr.FileContent("go.mod")
+ return err == nil
+}
+
func getDescription(path string) (desc string) {
db, err := os.ReadFile(filepath.Join(path, "description"))
if err == nil {