1 files changed,
37 insertions(+),
0 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-02-13 00:07:29 +0200
Authored at:
2026-02-11 18:57:27 +0200
Change ID:
nsztyyooomlokuxtlwlstvrxksnporsz
Parent:
b6e1830
M
internal/config/config.go
ยทยทยท 75 75 return nil, err 76 76 } 77 77 78 + config.ensureDefaults() 79 + 78 80 if verr := config.validate(); verr != nil { 79 81 return nil, verr 80 82 } 81 83 82 84 return &config, nil 85 +} 86 + 87 +func (c *Config) ensureDefaults() { 88 + // ports 89 + if c.Server.Port == 0 { 90 + c.Server.Port = 8080 91 + } 92 + 93 + if c.SSH.Port == 0 { 94 + c.SSH.Port = 2222 95 + } 96 + 97 + // meta 98 + if c.Meta.Title == "" { 99 + c.Meta.Title = "my cgit" 100 + } 101 + 102 + // repos 103 + if len(c.Repo.Masters) == 0 { 104 + c.Repo.Masters = []string{"master", "main"} 105 + } 106 + 107 + if len(c.Repo.Readmes) == 0 { 108 + c.Repo.Readmes = []string{ 109 + "README.md", "readme.md", 110 + "README.html", "readme.html", 111 + "README.txt", "readme.txt", 112 + "readme", 113 + } 114 + } 115 + 116 + // mirroring 117 + if c.Mirror.Interval == "" { 118 + c.Mirror.Interval = "8h" 119 + } 83 120 } 84 121 85 122 func (c Config) validate() error {