diff --git a/config/config.go b/config/config.go index 17c97d0e9..f36c94331 100644 --- a/config/config.go +++ b/config/config.go @@ -1,8 +1,6 @@ package config import ( - "log" - "gopkg.in/yaml.v2" "fmt" @@ -10,7 +8,6 @@ import ( "path/filepath" "soft-serve/git" - "github.com/gliderlabs/ssh" gg "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/object" ) @@ -30,7 +27,7 @@ type User struct { Name string `yaml:"name"` Admin bool `yaml:"admin"` PublicKey string `yaml:"public-key"` - CollabRepos []string `yaml:"collab_repos"` + CollabRepos []string `yaml:"collab-repos"` } type Repo struct { @@ -71,13 +68,6 @@ func NewConfig(host string, port int, pk string, rs *git.RepoSource) (*Config, e return cfg, nil } -func (cfg *Config) Pushed(repo string, pk ssh.PublicKey) { - err := cfg.reload() - if err != nil { - log.Printf("error reloading after push: %s", err) - } -} - func (cfg *Config) reload() error { err := cfg.Source.LoadRepos() if err != nil { diff --git a/config/auth.go b/config/git.go similarity index 82% rename from config/auth.go rename to config/git.go index 879f694dd..0e559508f 100644 --- a/config/auth.go +++ b/config/git.go @@ -7,6 +7,18 @@ import ( "github.com/gliderlabs/ssh" ) +func (cfg *Config) Push(repo string, pk ssh.PublicKey) { + log.Printf("git push: %s", repo) + err := cfg.reload() + if err != nil { + log.Printf("error reloading after push: %s", err) + } +} + +func (cfg *Config) Fetch(repo string, pk ssh.PublicKey) { + log.Printf("git fetch: %s", repo) +} + func (cfg *Config) AuthRepo(repo string, pk ssh.PublicKey) gm.AccessLevel { return cfg.accessForKey(repo, pk) } diff --git a/main.go b/main.go index 3992f3b28..9ee1f8d3b 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,7 @@ func main() { wish.WithHostKeyPath(scfg.KeyPath), wish.WithMiddlewares( bm.Middleware(tui.SessionHandler(cfg)), - gm.MiddlewareWithPushCallback(scfg.RepoPath, cfg, cfg.Pushed), + gm.Middleware(scfg.RepoPath, cfg), lm.Middleware(), ), )