git: add unlisted repositories
Marco Andronaco andronacomarco@gmail.com
Fri, 04 Oct 2024 15:52:08 +0000
4 files changed,
16 insertions(+),
7 deletions(-)
M
config/config.go
→
config/config.go
@@ -14,6 +14,7 @@ ScanPath string `yaml:"scanPath"`
Readme []string `yaml:"readme"` MainBranch []string `yaml:"mainBranch"` Ignore []string `yaml:"ignore,omitempty"` + Unlisted []string `yaml:"unlisted,omitempty"` } `yaml:"repo"` Dirs struct { Templates string `yaml:"templates"`
M
readme
→
readme
@@ -61,6 +61,7 @@ • 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.ignore: repos to ignore, relative to scanPath. +• repo.unlisted: repos to hide, 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.isUnlisted(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) isUnlisted(name string) bool { + for _, i := range d.c.Repo.Unlisted { + if name == i { + return true + } + } + + return false +} + func (d *deps) isIgnored(name string) bool { for _, i := range d.c.Repo.Ignore { if name == i {