summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f448b4b)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
; Runs `git pull` on all the git repositories in a directory
; 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])
-
-(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"))
(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)
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)))))
dest (io/file destination)
fs (FileSystems/newFileSystem (.toPath zip-file) nil)
file-in-zip (.getPath fs source (into-array String []))]
dest (io/file destination)
fs (FileSystems/newFileSystem (.toPath zip-file) nil)
file-in-zip (.getPath fs source (into-array String []))]
- (Files/copy file-in-zip (.toPath dest)
+ (Files/copy file-in-zip
+ (.toPath dest)
(into-array CopyOption [StandardCopyOption/REPLACE_EXISTING]))))
(into-array CopyOption [StandardCopyOption/REPLACE_EXISTING]))))
(if (.startsWith s "~")
(clojure.string/replace-first s "~" (System/getProperty "user.home"))
s))
(if (.startsWith s "~")
(clojure.string/replace-first s "~" (System/getProperty "user.home"))
s))
'[babashka.curl :as curl]
'[babashka.fs :as fs])
'[babashka.curl :as curl]
'[babashka.fs :as fs])
-(defn babashka-latest-version []
+(defn babashka-latest-version
+ []
(-> (curl/get "https://api.github.com/repos/babashka/babashka/tags")
:body
(json/parse-string true)
(-> (curl/get "https://api.github.com/repos/babashka/babashka/tags")
:body
(json/parse-string true)
(defn download-binary
[url destination]
(defn download-binary
[url destination]
- (io/copy
- (:body (curl/get url {:as :stream}))
- (io/file destination)))
+ (io/copy (:body (curl/get url {:as :stream})) (io/file destination)))
(defn get-download-url
[version architecture]
(defn get-download-url
[version architecture]
- (str "https://github.com/babashka/babashka/releases/download/v" version "/babashka-"
- version "-" architecture ".zip"))
+ (str "https://github.com/babashka/babashka/releases/download/v"
+ version
+ "/babashka-"
+ version
+ "-"
+ architecture
+ ".zip"))
(defn check-latest
[version]
(defn check-latest
[version]
(download-binary url output)))
(when (= *file* (System/getProperty "babashka.file"))
(download-binary url output)))
(when (= *file* (System/getProperty "babashka.file"))
- (let [architecture "linux-static-amd64" ;; TODO support multiple architectures
+ (let [architecture "linux-static-amd64" ;; TODO support multiple
+ ;; architectures
zip-file "babashka.zip"
destination (expand-home "~/bin/bb")
version (babashka-latest-version)]
zip-file "babashka.zip"
destination (expand-home "~/bin/bb")
version (babashka-latest-version)]