(defn read-git-head
"Reads the value of HEAD and returns a commit SHA1."
[git-dir]
(let [head (.trim (slurp (str (file git-dir "HEAD"))))]
(if-let [ref-path (second (re-find #"ref: (\S+)" head))]
(read-git-ref git-dir ref-path)
head)))
Comments top
No comments for read-git-head. Log in to add a comment.