Merge branch 'git-daemon-export-files'
4 files changed, 24 insertions(+), 6 deletions(-)
M config.yaml → config.yaml
@@ -8,6 +8,7 @@ - README.md mainBranch: - master - main + checkGitDaemonExportOk: false dirs: templates: ./templates static: ./static
M config/config.go → config/config.go
@@ -10,11 +10,12 @@ ) type Config struct { Repo struct { - ScanPath string `yaml:"scanPath"` - Readme []string `yaml:"readme"` - MainBranch []string `yaml:"mainBranch"` - Ignore []string `yaml:"ignore,omitempty"` - Unlisted []string `yaml:"unlisted,omitempty"` + ScanPath string `yaml:"scanPath"` + Readme []string `yaml:"readme"` + MainBranch []string `yaml:"mainBranch"` + Ignore []string `yaml:"ignore,omitempty"` + Unlisted []string `yaml:"unlisted,omitempty"` + CheckGitDaemonExportOk bool `yaml:"checkGitDaemonExportOk"` } `yaml:"repo"` Dirs struct { Templates string `yaml:"templates"`
M readme → readme
@@ -42,6 +42,7 @@ - main ignore: - foo - bar + checkGitDaemonExportOk: false dirs: templates: ./templates static: ./static@@ -63,6 +64,7 @@ • 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. +• repo.checkGitDaemonExportOk: when true, only show repos that can be exported by the git daemon • server.name: used for go-import meta tags and clone URLs. • meta.syntaxHighlight: this is used to select the syntax theme to render. If left blank or removed, the native theme will be used. If an invalid theme is set in this field,
M routes/routes.go → routes/routes.go
@@ -2,6 +2,7 @@ package routes import ( "compress/gzip" + "errors" "fmt" "html/template" "log"@@ -52,7 +53,20 @@ log.Printf("securejoin error: %v", err) d.Write404(w) return } - + if d.c.Repo.CheckGitDaemonExportOk { + gdPath, err := securejoin.SecureJoin(path, "git-daemon-export-ok") + if err != nil { + log.Printf("securejoin error: %v", err) + d.Write404(w) + return + } + if _, err := os.Stat(gdPath); err != nil { + if !errors.Is(err, os.ErrNotExist) { + log.Println(err) + } + continue + } + } gr, err := git.Open(path, "") if err != nil { log.Println(err)