Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active March 16, 2022 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/123ad8a889e3261178054ee3867a8a3c to your computer and use it in GitHub Desktop.
Save borkdude/123ad8a889e3261178054ee3867a8a3c to your computer and use it in GitHub Desktop.
find_git_dirs.clj
(require '[babashka.fs :as fs])
(let [counter (volatile! 0)]
(fs/walk-file-tree "." {:pre-visit-dir (fn [d _]
(if (= ".git" (fs/file-name d))
(do (vswap! counter inc )
:skip-subtree)
:continue))})
@counter)
;; $ time bb /tmp/find_git_dirs.clj
;; 136
;; bb /tmp/find_git_dirs.clj 0.23s user 0.63s system 99% cpu 0.861 total
;; $ time find . -type d -name .git | wc -l
;; 136
;; find . -type d -name .git 0.16s user 1.63s system 75% cpu 2.377 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment