Skip to content

Commit

Permalink
using deferred to run github reply call
Browse files Browse the repository at this point in the history
  • Loading branch information
wandersoncferreira committed Oct 10, 2021
1 parent 04c1d45 commit 3d09efc
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions github-review.el
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,36 @@ CALLBACK will be called back when done"

(defun github-review-post-review-replies (pr-alist replies callback)
"Submit replies to review comments inline."
(let-alist pr-alist
(-map
(lambda (comment)
(let* ((path (a-get comment 'path))
(position (a-get comment 'position))
(comment-id (alist-get (s-concat path
":"
(number-to-string position))
github-review-pos->databaseid
nil nil 'equal))
(body (a-get comment 'body)))
(ghub-post (format "/repos/%s/%s/pulls/%s/comments/%s/replies"
.owner .repo .num comment-id)
nil
:payload (a-alist 'body body)
:headers github-review-diffheader
:auth 'github-review
:host (github-review-api-host pr-alist)
:callback (lambda (&rest _))
:errorback #'github-review-errback)))
replies)
(funcall callback)))
(deferred:$
(deferred:loop
replies
(lambda (comment)
(let-alist pr-alist
(let* ((path (a-get comment 'path))
(position (a-get comment 'position))
(comment-id (alist-get (s-concat path
":"
(number-to-string position))
github-review-pos->databaseid
nil nil 'equal))
(body (a-get comment 'body)))
(ghub-post (format "/repos/%s/%s/pulls/%s/comments/%s/replies"
.owner .repo .num comment-id)
nil
:payload (a-alist 'body body)
:headers github-review-diffheader
:auth 'github-review
:host (github-review-api-host pr-alist)
:callback (lambda (&rest _))
:errorback #'github-review-errback)))))

(deferred:nextc it
(lambda (x)
(funcall callback)))

(deferred:error it
(lambda (err)
(message "Got an error from the Github Reply API %S!" err)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Code review file parsing ;;
Expand Down

0 comments on commit 3d09efc

Please sign in to comment.