Skip to content

Commit

Permalink
Remove some dead code
Browse files Browse the repository at this point in the history
This used to be used in a previous iteration of the Resyntax and GitHub integration, but it isn't used anymore. Deleting it lets us get rid of the `uri-old` dependency. Fixes #225.
  • Loading branch information
jackfirth committed Aug 23, 2024
1 parent 165dccf commit c5c9111
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 65 deletions.
3 changes: 1 addition & 2 deletions info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"fmt"
"guard"
"rackunit-lib"
"rebellion"
"uri-old"))
"rebellion"))


(define build-deps
Expand Down
64 changes: 1 addition & 63 deletions private/github.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,24 @@


(require json
net/url
net/url-connect
racket/list
racket/match
racket/pretty
racket/sequence
racket/string
rebellion/collection/list
rebellion/streaming/reducer
rebellion/streaming/transducer
rebellion/type/record
resyntax/private/refactoring-result
resyntax/private/line-replacement
resyntax/private/run-command
resyntax/private/string-indent
resyntax/private/source
uri-old)
resyntax/private/source)


;@----------------------------------------------------------------------------------------------------


; https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
(define github-token
(make-parameter (getenv "GITHUB_TOKEN") #false 'github-token))


; Returns the API URL. For example: `https://api.github.com`.
(define github-api-url
(make-parameter (getenv "GITHUB_API_URL") #false 'github-api-url))


(define-record-type github-review-request
(owner-repo pull-number body event comments))

Expand Down Expand Up @@ -90,61 +76,13 @@
'side end-side)))


; https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
(define (github-review-request-url req)
(string->url
(format "~a/repos/~a/pulls/~a/reviews"
(github-api-url)
(github-review-request-owner-repo req)
(github-review-request-pull-number req))))


(define (github-review-request-send req)
(parameterize ([current-https-protocol 'secure])
(define response-port
(post-pure-port
(github-review-request-url req)
(jsexpr->bytes (github-review-request-jsexpr req))
; https://docs.github.com/en/rest/reference/pulls#list-review-comments-in-a-repository-preview-notices
(list "Accept: application/vnd.github.comfort-fade-preview+json"
(format "Authorization: Bearer ~a" (github-token)))))
(define response-or-eof (read-json response-port))
(if (eof-object? response-or-eof)
(error (format "No response data for request to ~a"
(github-review-request-url req)))
response-or-eof)))


(define (github-new-issue-url #:owner owner
#:repository repo
#:title title
#:body body
#:labels [labels #()])
(define label-string
(transduce labels
(mapping symbol->string)
(mapping uri-escape-i)
#:into (join-into-string ",")))
(define label-part (if (equal? label-string "") "" (format "&labels=~a" label-string)))
(format "https://github.com/~a/~a/issues/new?title=~a&body=~a~a"
(uri-escape-i owner)
(uri-escape-i repo)
(uri-escape-i title)
(uri-escape-i body)
label-part))


(define (git-path path)
(string-split (run-command "git" "ls-tree" "-r" "-z" "--name-only" "HEAD" path) "\0"))


(define git-pr-ref-regexp #rx"^refs/pull/([0-9]+)/merge$")


(define (git-pr-ref? ref)
(regexp-match git-pr-ref-regexp ref))


(define (git-ref->pr-number ref)
(match ref
[(regexp git-pr-ref-regexp (list _ num))
Expand Down

0 comments on commit c5c9111

Please sign in to comment.