Remove RepoSource from config.Config and remove Server.AppConfig

Ayman Bagabas created

Change summary

config/config.go          | 10 +---------
internal/config/config.go |  2 +-
server/server.go          |  2 --
3 files changed, 2 insertions(+), 12 deletions(-)

Detailed changes

config/config.go 🔗

@@ -3,7 +3,6 @@ package config
 import (
 	"log"
 
-	"github.com/charmbracelet/soft/internal/git"
 	"github.com/charmbracelet/soft/stats"
 	"github.com/meowgorithm/babyenv"
 )
@@ -15,7 +14,6 @@ type Config struct {
 	KeyPath         string `env:"SOFT_SERVE_KEY_PATH" default:".ssh/soft_serve_server_ed25519"`
 	RepoPath        string `env:"SOFT_SERVE_REPO_PATH" default:".repos"`
 	InitialAdminKey string `env:"SOFT_SERVE_INITIAL_ADMIN_KEY" default:""`
-	RepoSource      *git.RepoSource
 	Stats           stats.Stats
 }
 
@@ -27,16 +25,10 @@ func DefaultConfig() *Config {
 	if err != nil {
 		log.Fatalln(err)
 	}
-	rs := git.NewRepoSource(scfg.RepoPath)
-	return scfg.WithRepoSource(rs).WithStats(stats.NewStats())
+	return scfg.WithStats(stats.NewStats())
 }
 
 func (cfg *Config) WithStats(s stats.Stats) *Config {
 	cfg.Stats = s
 	return cfg
 }
-
-func (cfg *Config) WithRepoSource(rs *git.RepoSource) *Config {
-	cfg.RepoSource = rs
-	return cfg
-}

internal/config/config.go 🔗

@@ -48,7 +48,7 @@ func NewConfig(cfg *config.Config) (*Config, error) {
 	host := cfg.Host
 	port := cfg.Port
 	pk := cfg.InitialAdminKey
-	rs := cfg.RepoSource
+	rs := git.NewRepoSource(cfg.RepoPath)
 	c := &Config{
 		Cfg: cfg,
 	}

server/server.go 🔗

@@ -18,7 +18,6 @@ import (
 type Server struct {
 	SSHServer *ssh.Server
 	Config    *config.Config
-	AppConfig *appCfg.Config
 }
 
 // NewServer returns a new *ssh.Server configured to serve Soft Serve. The SSH
@@ -49,7 +48,6 @@ func NewServer(cfg *config.Config) *Server {
 	return &Server{
 		SSHServer: s,
 		Config:    cfg,
-		AppConfig: ac,
 	}
 }