Compare commits

..

No commits in common. "872190811fbf025d33d3824dcd2961ab9568ba3b" and "9db3929117e025b05a2db6e1e1c5c8cb43a2458b" have entirely different histories.

2 changed files with 9 additions and 35 deletions

View file

@ -15,8 +15,6 @@ With [[https://github.com/radian-software/straight.el][straight]] and [[https://
:straight (ghpr :type git :host github :repo "priime0/ghpr.el"))
#+end_src
You need a [[https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens][personal access token]] stored in[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Authentication.html][.authinfo(.gpg)]] with =repo= permissions, which will be used to handle interactions with the GitHub API for pull requests, including listing PRs and submitting reviews.
** Feature set
Current features:

View file

@ -265,22 +265,18 @@ of comment lines and next-index is the index after the last comment line."
(defun ghpr--collect-review-body ()
"Collect review body comment from the top of the buffer.
Returns the body text as a string, or nil if no body found.
Body is everything from the start until the first line with special characters (>, <).
Processes the body to join lines separated by single newlines."
Body is everything from the start until the first line with special characters (>, <)."
(let* ((lines (vconcat (split-string (buffer-string) "\n")))
(body-lines '())
(index 0)
(has-content nil))
(index 0))
(while (and (< index (length lines))
(not (ghpr--special-line-p (aref lines index))))
(let ((line (aref lines index)))
(if (string-empty-p (string-trim line))
(push "" body-lines)
(push (substring-no-properties line) body-lines)
(setq has-content t)))
(unless (string-empty-p (string-trim line))
(push (substring-no-properties line) body-lines)))
(setq index (1+ index)))
(when has-content
(ghpr--process-review-comment (string-join (reverse body-lines) "\n")))))
(when body-lines
(string-join (reverse body-lines) "\n"))))
(defun ghpr--skip-review-body (lines)
"Skip to the first line with special characters (>, <) to get past the body.
@ -329,24 +325,6 @@ Errors if the comment is missing required fields or has empty body."
(position . ,position)
(body . ,comment-body))))
(defun ghpr--process-review-comment (comment-text)
"Process COMMENT-TEXT by joining lines separated by single newlines.
Lines separated by only a single newline are joined with a space.
Lines separated by double newlines (blank line between) are preserved as paragraphs."
(let* ((paragraphs (split-string comment-text "\n\n" t))
(processed-paragraphs
(mapcar (lambda (paragraph)
(string-join (split-string paragraph "\n" t) " "))
paragraphs)))
(string-join processed-paragraphs "\n\n")))
(defun ghpr--process-comment-entry (comment)
"Process a single comment entry by applying comment text processing.
Returns a new comment entry with the processed comment text."
(let ((processed-comment-text (ghpr--process-review-comment (alist-get 'comment comment))))
(cons (cons 'comment processed-comment-text)
(assq-delete-all 'comment comment))))
(defun ghpr--build-comment-with-context (comment-lines comment-start-index lines)
"Build a comment entry with GitHub API context for COMMENT-LINES.
Uses COMMENT-START-INDEX to find the preceding code line in LINES.
@ -373,12 +351,10 @@ Returns t if validation passes, nil otherwise."
"Collect all inline review comments from the current buffer.
Returns an alist of comments with their associated diff lines and GitHub API context.
Multi-line comments are grouped together until the next line with angle brackets.
Skips the review body at the top of the buffer.
Processes comments to join lines separated by single newlines."
Skips the review body at the top of the buffer."
(let* ((lines (vconcat (split-string (buffer-string) "\n")))
(body-end-index (ghpr--skip-review-body lines))
(raw-comments (ghpr--collect-inline-comments-after-body lines body-end-index)))
(mapcar #'ghpr--process-comment-entry raw-comments)))
(body-end-index (ghpr--skip-review-body lines)))
(ghpr--collect-inline-comments-after-body lines body-end-index)))
(defun ghpr-collect-review-comments ()
"Interactive command to collect and display review comments from current buffer."