Created
May 8, 2017 21:52
-
-
Save anonymous/0c28b772369921bf30c8fd079cc952d7 to your computer and use it in GitHub Desktop.
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
(ns gh-finder.core | |
(:require [tentacles.repos :as repos]) | |
(:require [clojure.java.io :as io]) | |
(:require [clj-yaml.core :as yaml]) | |
(:gen-class)) | |
(defn auth | |
"get an authentication token from the environment" | |
[] | |
{:auth (System/getenv "GITHUB_TOKEN")}) | |
(defn make-redirect | |
"given a repository, build a redirect to its pages.github.io address" | |
[repo] | |
(spit (str "2017-01-01-" (:name repo) ".md") | |
(str "---\n" | |
(yaml/generate-string { | |
:layout "redirect_external" | |
:categories "redirect" | |
:permalink (str "/" (:name repo) "/") | |
:redirect (str "https://tmcw.github.io/" (:name repo)) | |
}) "---"))) | |
(defn get-branches | |
"get branches given a repository map" | |
[repo] | |
(when | |
(some (partial = "gh-pages") | |
(map :name (repos/branches | |
(:login (:owner repo)) | |
(:name repo) | |
(auth)))) | |
repo)) | |
(defn -main | |
"print a list of repositories you own that have gh-pages branches" | |
[& args] | |
(->> | |
(merge (auth) {:all-pages true}) | |
(repos/user-repos "tmcw") | |
(map get-branches) | |
(remove nil?) | |
(map make-redirect) | |
;; (map (partial format "- %s")) | |
;; (clojure.string/join "\n") | |
;; (print) | |
)) |
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
(defproject gh-finder "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [ | |
[clj-yaml "0.4.0"] | |
[hiccup "1.0.5"] | |
[irresponsible/tentacles "0.6.1"] | |
[org.clojure/clojure "1.8.0"]] | |
:plugins [[lein-cljfmt "0.5.6"]] | |
:main ^:skip-aot gh-finder.core | |
:target-path "target/%s" | |
:profiles {:uberjar {:aot :all}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment