Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
FieryCod
committed
Dec 27, 2018
1 parent
3ceaae8
commit b174c63
Showing
3 changed files
with
32 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
(ns codcheck.github) | ||
(ns codcheck.github | ||
(:require | ||
[cheshire.core :as cheshire] | ||
[clj-http.client :as http])) | ||
|
||
(def api-url "https://api.github.com/") | ||
|
||
(defn installation-token-url | ||
[installation-id] | ||
(str api-url "app/installations/" installation-id "/access_tokens")) | ||
|
||
(defn comment-pr-url | ||
[repo-owner repo-name pr-number] | ||
(str api-url "repos/" repo-owner "/" repo-name "/issues/" pr-number "/comments")) | ||
|
||
(defn comment-on-pr | ||
([installation-token repo-owner repo-name pr-number comment-message] | ||
(comment-on-pr installation-token repo-owner repo-name pr-number comment-message false)) | ||
|
||
([installation-token repo-owner repo-name pr-number comment-message async?] | ||
(let [comment-url (comment-pr-url repo-owner repo-name pr-number) | ||
headers {:authorization (str "token " installation-token)} | ||
opts {:headers headers | ||
:async? async? | ||
:accept "application/vnd.github.machine-man-preview+json" | ||
:body (cheshire/encode {:body comment-message})}] | ||
(http/post comment-url opts)))) | ||
|
||
;; (comment (comment-on-pr "some-token" "FieryCod" "codcheck-lint-demo" 1 "a-message")) |
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