Clojure makes working with functions a real delight

Created: Feb 21, 2021Published: Mar 28, 2023Last modified: Apr 05, 2023
No tags
Word count: 27

this is such a great unit of code to be able to work with. Keep that feedback loop tight!

(defn path->git-repo
  "NOTE does not check if the path is actually for a git repo.
  just parses the string based on '/'"
  [path]
  (let [[& parts] (string/split path #"/")
        repo-name (last parts)
        owner (last (butlast parts))]
    {:repo/name repo-name
     :repo/path path
     :repo/owner owner
     :git/repo path}))

(comment
  (path->git-repo "/home/russ/russmatney/yodo")
  (path->git-repo "/home/russ/.zsh"))