Skip to content

Instantly share code, notes, and snippets.

@hiredman
Created December 3, 2008 08:04
Show Gist options
  • Save hiredman/31479 to your computer and use it in GitHub Desktop.
Save hiredman/31479 to your computer and use it in GitHub Desktop.
svn info for clojurebot
(def svn-command "svn -v --xml --limit 5 log https://clojure.svn.sourceforge.net/svnroot/clojure")
(defn svn-summaries
"takes output of clojure.xml/parse on svn's xml log, returns
a vector of [rev-number commit-message]"
[tag-map]
(map (fn [x]
[(.parseInt Integer (:revision (:attrs x)))
(first
(:content
(first
(filter #(= (:tag %) :msg)
(:content x)))))])
(:content tag-map)))
;; needs fixing.
(defn svn-message
[summaries]
(dosync
(let [a (filter #(> (first %)
(.parseInt Integer (@dict-is "latest")))
(reverse summaries))]
(when a
(do
(dorun
(map #(sendMsg *bot*
"#clojure"
(str "svn rev " (first %) "; " (last %)))
a))
(alter dict-is
assoc "latest" (str (first (first summaries)))))))))
(defn svn-xml-stream
"get the xml stream from svn"
[]
(.getInputStream (.. Runtime getRuntime (exec svn-command))))
(defn svn-notifier-thread []
(send-off (agent nil)
(fn this [& _]
(svn-message
(svn-summaries
(clojure.xml/parse (svn-xml-stream))))
(Thread/sleep (* 5 60000))
(send-off *agent* this))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment