wandersoncferreira / code-review

Code Reviews in Emacs
https://wandersoncferreira.github.io/code-review/
GNU General Public License v3.0
462 stars 49 forks source link

wrong-type-argument sequencep #<subr code-review-section--magit-diff-insert-file-section> #227

Closed jkdufair closed 1 year ago

jkdufair commented 1 year ago

Pretty psyched to try out this package! Thanks for taking a look a this.

Describe the bug Error executing code-review-start

To Reproduce Steps to reproduce the behavior: code-review start then provide any GitLab URL

Tried setting debug-on-error to t, to no avail

Expected behavior See a code review buffer

Screenshots Attempt #1: *messages* Fetch diff PR...60% deferred error : (wrong-type-argument sequencep #) code-review-error.log Fri Oct 21 10:11:51 2022 - code-review--build-buffer - (wrong-number-of-arguments # 8)

Attempt #2 (different URL) *messages* Fetch diff PR...100% deferred error : (wrong-type-argument sequencep #) code-review-error.log code-review-error.log Fri Oct 21 10:11:51 2022 - code-review--build-buffer - (wrong-number-of-arguments # 8)

Desktop (please complete the following information):

matasar commented 1 year ago

Looks like the signature changed for that function, which code-review advises. I can make this work again by doing:

(defun code-review-section--magit-diff-insert-file-section
    (file orig status modes rename header binary long-status)
  "Overwrite the original Magit function on `magit-diff.el' FILE.
ORIG, STATUS, MODES, RENAME, HEADER, BINARY and LONG-STATUS are arguments of the original fn."

  ;;; --- beg -- code-review specific code.
  ;;; I need to set a reference point for the first hunk header
  ;;; so the positioning of comments is done correctly.
  (let* ((raw-path-name (substring-no-properties file))
         (clean-path (if (string-prefix-p "b/" raw-path-name)
                         (replace-regexp-in-string "^b\\/" "" raw-path-name)
                       raw-path-name)))
    (code-review-db--curr-path-update clean-path))
    ;;; --- end -- code-review specific code.
  (insert ?\n)
  (magit-insert-section section
    (file file (or (equal status "deleted")
                   (derived-mode-p 'magit-status-mode)))
    (insert (propertize (format "%-10s %s" status
                                (if (or (not orig) (equal orig file))
                                    file
                                  (format "%s -> %s" orig file)))
                        'font-lock-face 'magit-diff-file-heading))
    (when long-status
      (insert (format " (%s)" long-status)))
    (magit-insert-heading)
    (unless (equal orig file)
      (oset section source orig))
    (oset section header header)
    (when modes
      (magit-insert-section (hunk '(chmod))
        (insert modes)
        (magit-insert-heading)))
    (when rename
      (magit-insert-section (hunk '(rename))
        (insert rename)
        (magit-insert-heading)))
    (when (string-match-p "Binary files.*" header)
      (magit-insert-section (code-review-binary-file-section file)
        (insert (propertize "Visit file"
                            'face 'code-review-request-review-face
                            'mouse-face 'highlight
                            'help-echo "Visit the file in Dired buffer"
                            'keymap 'code-review-binary-file-section-map))
        (magit-insert-heading)))
    (magit-wash-sequence #'magit-diff-wash-hunk)))
matasar commented 1 year ago

Just filed #228

wandersoncferreira commented 1 year ago

Merged, thanks @matasar