5 files changed,
20 insertions(+),
22 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-05-15 15:35:53 +0300
Authored at:
2026-05-15 15:21:41 +0300
Change ID:
yoznxnwlnvqmrymtorspwukokulyuqrw
Parent:
872559d
M
flake.nix
路路路 114 114 default = 8080; 115 115 description = "Website port"; 116 116 }; 117 - log_file = mkOption { 118 - type = types.str; 119 - default = ""; 120 - description = "File to write mugit logs"; 121 - }; 122 117 }; 123 118 options.repo = { 124 119 dir = mkOption { 路路路 152 147 type = types.listOf types.str; 153 148 default = []; 154 149 description = "List of public ssh keys which are allows to do git pushes, and access private repositories"; 150 + }; 151 + log_file = mkOption { 152 + type = types.str; 153 + default = ""; 154 + description = "File to write mugit logs (defaults to `repo.dir`/mugit-ssh.log)"; 155 155 }; 156 156 }; 157 157 options.mirror = {
M
internal/cli/cli.go
路路路 128 128 }, 129 129 { 130 130 Name: "shell", 131 - Description: "sshd things", // TODO: update me 131 + Description: "git over sshd", 132 132 Action: c.sshShellAction, 133 133 Commands: []*cli.Command{ 134 134 { 路路路 143 143 } 144 144 145 145 func (c *Cli) setupLogger() error { 146 - logDir := filepath.Dir(c.cfg.Server.LogFile) 146 + logDir := filepath.Dir(c.cfg.SSH.LogFile) 147 147 if err := os.MkdirAll(logDir, 0o755); err != nil { 148 148 return fmt.Errorf("failed to create log directory: %w", err) 149 149 } 150 150 151 - logOutput, err := os.OpenFile(c.cfg.Server.LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) 151 + logOutput, err := os.OpenFile(c.cfg.SSH.LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) 152 152 if err != nil { 153 153 return fmt.Errorf("failed to open log file: %w", err) 154 154 }
M
internal/cli/serve.go
路路路 16 16 ) 17 17 18 18 func (c *Cli) serveAction(ctx context.Context, cmd *cli.Command) error { 19 - if err := c.setupLogger(); err != nil { 20 - return err 21 - } 22 - 23 19 httpServer := &http.Server{ 24 20 Addr: net.JoinHostPort(c.cfg.Server.Host, strconv.Itoa(c.cfg.Server.Port)), 25 21 Handler: handlers.InitRoutes(c.cfg),
M
internal/config/config.go
路路路 18 18 ) 19 19 20 20 type ServerConfig struct { 21 - Host string `yaml:"host"` 22 - Port int `yaml:"port"` 23 - LogFile string `yaml:"log_file"` 21 + Host string `yaml:"host"` 22 + Port int `yaml:"port"` 24 23 } 25 24 26 25 type MetaConfig struct { 路路路 36 35 } 37 36 38 37 type SSHConfig struct { 39 - Enable bool `yaml:"enable"` 40 - User string `yaml:"user"` 41 - Keys []string `yaml:"keys"` 38 + Enable bool `yaml:"enable"` 39 + User string `yaml:"user"` 40 + Keys []string `yaml:"keys"` 41 + LogFile string `yaml:"log_file"` 42 42 } 43 43 44 44 type MirrorConfig struct { 路路路 117 117 } 118 118 119 119 func (c *Config) ensureDefaults() { 120 - if c.Server.LogFile == "" { 121 - c.Server.LogFile = filepath.Join(c.Repo.Dir, "mugit.log") 122 - } 123 - 124 120 // http 125 121 if c.Server.Port == 0 { 126 122 c.Server.Port = 8080 路路路 144 140 // ssh 145 141 if c.SSH.User == "" { 146 142 c.SSH.User = "git" 143 + } 144 + if c.SSH.LogFile == "" { 145 + c.SSH.LogFile = filepath.Join(c.Repo.Dir, "mugit-ssh.log") 147 146 } 148 147 149 148 // mirroring