 (defn git-project?
   [path]
   (.exists (git-file path)))
+
+(defn escape-html
+  [text]
+  (-> text
+      (string/replace "&" "&amp;")
+      (string/replace "<" "&lt;")
+      (string/replace ">" "&gt;")))
 
 (defn format-diff!
   [^ByteArrayOutputStream out ^DiffFormatter df ^DiffEntry diff]

(defn create-html
  [^Git git ^RevCommit commit]
  (clj->html
    [:div {:class "head"} (or (some-> commit .getFullMessage)
                              (utils/get-string :uncommitted-changes))]
    (when commit
      (list [:div (format (utils/get-string :author)

          df (doto (DiffFormatter. out)
               (.setRepository repo))
          [old-tree new-tree] (diff-trees repo commit)]
      (for [^DiffEntry diff (.scan df old-tree new-tree)
            :when (or (some? commit)
                      (not= DiffEntry$ChangeType/ADD (.getChangeType diff)))]
        (->> (format-diff! out df diff)
             string/split-lines
             (map escape-html)
             (map add-formatting)
             (#(conj % [:br] [:br])))))))

