diff --git a/CHANGELOG.md b/CHANGELOG.md index 93edf5e..9764027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] -Nothing yet. +### Added + +- Set a default `depth` in config.yaml and remove the hard-coded value. ## [0.1.0] diff --git a/internal/config/config.go b/internal/config/config.go index e29a8d8..6c0c41b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,6 +9,7 @@ import ( ) type Config struct { + Depth string `yaml:"depth"` Directories []string `yaml:"directories"` } diff --git a/internal/repositories/find.go b/internal/repositories/find.go index 73bd3dd..e8b0f28 100644 --- a/internal/repositories/find.go +++ b/internal/repositories/find.go @@ -6,6 +6,7 @@ import ( "os/exec" "strings" + "git-repo-updater/internal/config" "git-repo-updater/internal/utils" ) @@ -36,10 +37,15 @@ func FindInDirectory(dir string) (string, error) { } func splitPath(repoPath string) (string, string) { + cfg, err := config.Load() + + if err != nil { + } + parts := strings.SplitN(repoPath, ":", 2) repoPath = parts[0] - depth := "2" + depth := cfg.Depth if len(parts) == 2 { return parts[0], parts[1] diff --git a/todo.txt b/todo.txt index a085f11..3637a5f 100644 --- a/todo.txt +++ b/todo.txt @@ -1,8 +1,8 @@ * Load directories from a configuration file * Update the repositories within each directory. * Make depth configurable per directory. +* Set a default depth in config.yaml. -Set a default depth in config.yaml. Add unit tests. Add a `--dry-run` option. Complete README.