From: Joseph Nuthalapati Date: Mon, 29 Nov 2021 05:32:56 +0000 (+0530) Subject: git-pull-all: Fix failure on non-git directories X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/commitdiff_plain/269ff235d32dde012c671f258fcbdeba6504144f git-pull-all: Fix failure on non-git directories Signed-off-by: Joseph Nuthalapati --- diff --git a/git-pull-all b/git-pull-all index 6b0de16..78c4000 100755 --- a/git-pull-all +++ b/git-pull-all @@ -7,7 +7,16 @@ (def default-root ".") -(defn list-dirs [root] (filter #(.isDirectory %) (.listFiles (io/file root)))) +(defn has-git-repo + [dir] + (first (filter #(= ".git" %) + (map #(.getName %) + (filter #(.isDirectory %) (.listFiles (io/file dir))))))) + +(defn list-dirs + [root] + (filter #(has-git-repo %) + (filter #(.isDirectory %) (.listFiles (io/file root))))) (defn git-pull [dir] (p/process ["git" "-C" dir "pull" "--rebase"]))