all repos — legit @ 4881d9ea3d23204e6c2b7bb4118d5edf22b9425a

web frontend for git

git: allow hiding repositories
Marco Andronaco andronacomarco@gmail.com
Wed, 02 Oct 2024 12:05:54 +0200
commit

4881d9ea3d23204e6c2b7bb4118d5edf22b9425a

parent

fba146ac6867b13c40802c4d7a21a8a32571473c

4 files changed, 16 insertions(+), 7 deletions(-)

jump to
M config/config.goconfig/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 readmereadme

@@ -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.goroutes/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.goroutes/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 {