]> njoseph.me Git - babashka-scripts.git/blobdiff - git-pull-all
Shift from standalone scripts to babashka tasks
[babashka-scripts.git] / git-pull-all
diff --git a/git-pull-all b/git-pull-all
deleted file mode 100755 (executable)
index 78c4000..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /usr/bin/env bb
-; -*- mode: clojure -*-
-
-; Runs `git pull` on all the git repositories in a directory
-
-(require '[babashka.process :as p] '[clojure.java.io :as io])
-
-(def default-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"]))
-
-(when (= *file* (System/getProperty "babashka.file"))
-  (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)))))