legit/routes/util.go

42 lines
699 B
Go

package routes
import (
"fmt"
"os"
"path/filepath"
"strings"
"git.icyphox.sh/legit/git"
)
func isGoModule(gr *git.GitRepo) bool {
_, err := gr.FileContent("go.mod", false)
return err == nil
}
func getDescription(path string) (desc string) {
db, err := os.ReadFile(filepath.Join(path, "description"))
if err == nil {
desc = string(db)
} else {
desc = ""
}
return
}
func transformRelativeURLs(html, repoName, mainBranch string) string {
return strings.ReplaceAll(
html,
"=\"./",
fmt.Sprintf("=\"/%s/raw/%s/", repoName, mainBranch))
}
func (d *deps) isIgnored(name string) bool {
for _, i := range d.c.Repo.Ignore {
if name == i {
return true
}
}
return false
}