all repos — legit @ 823f7aea9ece5805367520be94f68b06e36e53d5

web frontend for git, written in go

Merge branch 'git-daemon-export-files'

Alan Pearce
commit

823f7aea9ece5805367520be94f68b06e36e53d5

parent

b97e2ba81f0f58e7b2029dacea2b4c0eb43c9403

4 files changed, 24 insertions(+), 6 deletions(-)

jump to
M config.yamlconfig.yaml
@@ -8,6 +8,7 @@ - README.md
mainBranch: - master - main + checkGitDaemonExportOk: false dirs: templates: ./templates static: ./static
M config/config.goconfig/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 readmereadme
@@ -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.goroutes/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)