1 files changed,
37 insertions(+),
0 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-02-13 00:07:29 +0200
Change ID:
nsztyyooomlokuxtlwlstvrxksnporsz
Parent:
b6e1830
M
internal/config/config.go
@@ -75,11 +75,48 @@ if config.Repo.Dir, err = filepath.Abs(config.Repo.Dir); err != nil {
return nil, err } + config.ensureDefaults() + if verr := config.validate(); verr != nil { return nil, verr } return &config, nil +} + +func (c *Config) ensureDefaults() { + // ports + if c.Server.Port == 0 { + c.Server.Port = 8080 + } + + if c.SSH.Port == 0 { + c.SSH.Port = 2222 + } + + // meta + if c.Meta.Title == "" { + c.Meta.Title = "my cgit" + } + + // repos + if len(c.Repo.Masters) == 0 { + c.Repo.Masters = []string{"master", "main"} + } + + if len(c.Repo.Readmes) == 0 { + c.Repo.Readmes = []string{ + "README.md", "readme.md", + "README.html", "readme.html", + "README.txt", "readme.txt", + "readme", + } + } + + // mirroring + if c.Mirror.Interval == "" { + c.Mirror.Interval = "8h" + } } func (c Config) validate() error {