From 6644029a7717e77aa79048ea2bd59465d8f0b12a Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 31 Jul 2025 21:59:07 +0100 Subject: [PATCH] Make depth configurable per path --- internal/repositories/find.go | 22 ++++++++++++++++++++-- todo.txt | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/internal/repositories/find.go b/internal/repositories/find.go index 0e0f764..84604a3 100644 --- a/internal/repositories/find.go +++ b/internal/repositories/find.go @@ -4,21 +4,26 @@ import ( "fmt" "log" "os/exec" + "strings" "git-repo-updater/internal/utils" ) func FindInDirectory(dir string) (string, error) { - expanded, err := utils.ExpandPath(dir) + repoPath, err := utils.ExpandPath(dir) if err != nil { log.Fatal(err) } - cmd := exec.Command("find", expanded, "-type", "d", "-name", ".git", "-mindepth", "1", "-maxdepth", "2") + repoPath, depth := splitPath(repoPath) + + cmd := exec.Command("find", repoPath, "-type", "d", "-name", ".git", "-mindepth", "1", "-maxdepth", depth) output, err := cmd.CombinedOutput() + fmt.Println(string(output)) + if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { exitCode := exitErr.ExitCode() @@ -31,3 +36,16 @@ func FindInDirectory(dir string) (string, error) { return string(output), nil } + +func splitPath(repoPath string) (string, string) { + parts := strings.SplitN(repoPath, ":", 2) + + repoPath = parts[0] + depth := "2" + + if len(parts) == 2 { + return parts[0], parts[1] + } + + return repoPath, depth +} diff --git a/todo.txt b/todo.txt index c146fa0..466277b 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ * Load directories from a configuration file * Update the repositories within each directory. +* Make depth configurable per directory. -Make depth configurable per directory. +Set a default depth in config.yaml.