Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better organize Clojure code, unpublish extension
- Loading branch information
Showing
7 changed files
with
180 additions
and
216 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns community-extensions.build | ||
(:require | ||
[clojure.java.io :as io] | ||
[clojure.java.shell :as shell] | ||
[clojure.string :as str] | ||
[community-extensions.core :as core])) | ||
|
||
(def args-map | ||
(apply array-map *command-line-args*)) | ||
|
||
(defn build [ext-id data] | ||
(let [dir (io/file "checkout" ext-id) | ||
{repo "source_repo" | ||
commit "source_commit"} data] | ||
(when-not (.exists dir) | ||
(.mkdirs dir) | ||
(core/sh "git" "clone" repo (str "checkout/" ext-id))) | ||
(shell/with-sh-dir dir | ||
(core/sh "git" "-c" "advice.detachedHead=false" "checkout" commit)))) | ||
|
||
(defn -main [& {:as args-map}] | ||
(doseq [[mode ext-id data] (core/diff args-map)] | ||
(cond | ||
(= "A" mode) (build ext-id data) | ||
(= "M" mode) (build ext-id data) | ||
(str/starts-with? "R" mode) :nop)) | ||
(shutdown-agents)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(ns community-extensions.core | ||
(:require | ||
[cheshire.core :as json] | ||
[clojure.java.io :as io] | ||
[clojure.java.shell :as shell] | ||
[clojure.string :as str])) | ||
|
||
(defn sh [& cmd] | ||
(apply println "[ sh ]" cmd) | ||
(let [{:keys [out err exit]} (apply shell/sh cmd)] | ||
(when-not (str/blank? err) | ||
(binding [*out* *err*] | ||
(println err))) | ||
(if (= 0 exit) | ||
(str/trim out) | ||
(throw (Exception. (str "Command '" (str/join " " cmd) "' failed with exit code " exit)))))) | ||
|
||
(defn diff [args-map] | ||
(let [{sha-from "--from" | ||
sha-to "--to"} args-map] | ||
(for [[mode path] (->> (sh "git" "diff" "--name-status" (or sha-from "HEAD~1") (or sha-to "HEAD")) | ||
(str/split-lines) | ||
(map #(str/split % #"\t"))) | ||
:when (str/starts-with? path "extensions/") | ||
:let [[_ user repo] (re-matches #"extensions/([^/]+)/([^/]+)\.json" path) | ||
ext-id (str user "+" repo) | ||
data (-> (io/file path) | ||
(slurp) | ||
(json/parse-string))]] | ||
[mode ext-id data]))) |
Oops, something went wrong.