git: allow hiding repositories
Marco Andronaco andronacomarco@gmail.com
Wed, 02 Oct 2024 12:05:54 +0200
4 files changed,
16 insertions(+),
7 deletions(-)
M
config/config.go
→
config/config.go
@@ -13,6 +13,7 @@ Repo struct {
ScanPath string `yaml:"scanPath"` Readme []string `yaml:"readme"` MainBranch []string `yaml:"mainBranch"` + Hide []string `yaml:"hide,omitempty"` Ignore []string `yaml:"ignore,omitempty"` } `yaml:"repo"` Dirs struct {
M
readme
→
readme
@@ -60,6 +60,7 @@ traverse subdirs yet.
• dirs: use this to override the default templates and static assets. • repo.readme: readme files to look for. • repo.mainBranch: main branch names to look for. +• repo.hide: repos to hide, relative to scanPath. • repo.ignore: repos to ignore, relative to scanPath. • server.name: used for go-import meta tags and clone URLs.
M
routes/routes.go
→
routes/routes.go
@@ -40,11 +40,12 @@
infos := []info{} for _, dir := range dirs { - if !dir.IsDir() || d.isIgnored(dir.Name()) { + name := dir.Name() + if !dir.IsDir() || d.isIgnored(name) || d.isHidden(name) { continue } - path := filepath.Join(d.c.Repo.ScanPath, dir.Name()) + path := filepath.Join(d.c.Repo.ScanPath, name) gr, err := git.Open(path, "") if err != nil { log.Println(err)@@ -58,14 +59,10 @@ log.Println(err)
return } - name := dir.Name() - - desc := getDescription(path) - infos = append(infos, info{ DisplayName: getDisplayName(name), Name: name, - Desc: desc, + Desc: getDescription(path), Idle: humanize.Time(c.Author.When), d: c.Author.When, })
M
routes/util.go
→
routes/util.go
@@ -30,6 +30,16 @@ }
return } +func (d *deps) isHidden(name string) bool { + for _, i := range d.c.Repo.Hide { + if name == i { + return true + } + } + + return false +} + func (d *deps) isIgnored(name string) bool { for _, i := range d.c.Repo.Ignore { if name == i {