Skip to content

Instantly share code, notes, and snippets.

@tatut
Created August 19, 2016 06:34
Show Gist options
  • Save tatut/8d824c031a6944314fb24c6965aca1fe to your computer and use it in GitHub Desktop.
Save tatut/8d824c031a6944314fb24c6965aca1fe to your computer and use it in GitHub Desktop.
Bitbar plugin to fetch Harja project's open PR:s
#!/usr/local/bin/planck
(ns github.core
(:require [planck.http :as http]
[planck.core :refer [spit slurp]]
[planck.shell :as sh]))
(def gh-url "https://api.github.com/")
(defn load-gh-uri [uri]
(sh/sh "curl" "-o" "/tmp/harja-pulls.json" (str gh-url uri))
(let [body (slurp "/tmp/harja-pulls.json")]
(try
(-> body js/JSON.parse js->clj)
(catch :default e
(println "Parse failure, see debug.json: " (str e))
(spit "/Users/tatuta/debug.json" body)))))
(def pulls
(try
(load-gh-uri "repos/finnishtransportagency/harja/pulls")
(catch js/Object e
(println "GH error\n---\n" e)
nil)))
(when pulls
(println (count pulls) "PRs")
(println "---")
(doseq [{number "number" title "title" url "html_url"
user "user" :as pull} pulls]
(println (str number ": " title " "
"(" (get user "login") ")"
"| href=" url))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment