X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/f448b4b287309fd5cede4bfebe5327fe6d4c6b3e..0b0f2aa39a06e77b1517f895a2c82946f684b568:/git-pull-all.clj diff --git a/git-pull-all.clj b/git-pull-all.clj index a8152d1..647db21 100755 --- a/git-pull-all.clj +++ b/git-pull-all.clj @@ -2,30 +2,28 @@ ; Runs `git pull` on all the git repositories in a directory -(require '[babashka.process :as p] - '[clojure.java.io :as io]) +(require '[babashka.process :as p] '[clojure.java.io :as io]) (def default-root ".") - -(defn list-dirs - [root] - (filter #(.isDirectory %) (.listFiles (io/file root)))) -(defn git-pull - [dir] - (p/process ["git" "-C" dir "pull" "--rebase"])) +(defn list-dirs [root] (filter #(.isDirectory %) (.listFiles (io/file root)))) + +(defn git-pull [dir] (p/process ["git" "-C" dir "pull" "--rebase"])) (when (= *file* (System/getProperty "babashka.file")) - (let [root (get (into [] *command-line-args*) 0 default-root) - dirs (list-dirs root) + (let [root (get (into [] *command-line-args*) 0 default-root) + dirs (list-dirs root) pulls (->> root list-dirs (map git-pull) doall) - outputs (map #(->> % p/check :out slurp) pulls)] - - ;; Print corresponding directory name when pulling - ;; Skip printing already up to date repos - (doseq [[dir out](filter #(not (.contains (second %) "is up to date.")) - (map vector dirs outputs))] - (println (str dir "\n" out))))) + outputs (map #(->> % + p/check + :out + slurp) + pulls)] + ;; Print corresponding directory name when pulling + ;; Skip printing already up to date repos + (doseq [[dir out] (filter #(not (.contains (second %) "is up to date.")) + (map vector dirs outputs))] + (println (str dir "\n" out)))))