Created
August 19, 2016 06:34
-
-
Save tatut/8d824c031a6944314fb24c6965aca1fe to your computer and use it in GitHub Desktop.
Bitbar plugin to fetch Harja project's open PR:s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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