2 ; -*- mode: clojure -*-
4 ; Runs `git pull` on all the git repositories in a directory
6 (require '[babashka.process :as p] '[clojure.java.io :as io])
12 (first (filter #(= ".git" %)
14 (filter #(.isDirectory %) (.listFiles (io/file dir)))))))
18 (filter #(has-git-repo %)
19 (filter #(.isDirectory %) (.listFiles (io/file root)))))
21 (defn git-pull [dir] (p/process ["git" "-C" dir "pull" "--rebase"]))
23 (when (= *file* (System/getProperty "babashka.file"))
24 (let [root (get (into [] *command-line-args*) 0 default-root)
35 ;; Print corresponding directory name when pulling
36 ;; Skip printing already up to date repos
37 (doseq [[dir out] (filter #(not (.contains (second %) "is up to date."))
38 (map vector dirs outputs))]
39 (println (str dir "\n" out)))))