Skip to content

Commit

Permalink
enable goto-source code from diff buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
wandersoncferreira committed Oct 10, 2021
1 parent 4d91dd6 commit 65975c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ configure the endpoint of your GitHub Enterprise installation, this should look
`github-review-view-comments-in-code-lines-outdated` to `t`, however we cannot
guarantee correct placement of these comments in the review buffer.

You can also enable replies to inline comments by setting
`github-review-reply-inline-comments` to `t`, this feature only works if
`github-review-view-comments-in-code-lines` is also set to `t`. This way, if
you include a comment right after a previous received comment in the diff
buffer, your new comment will be sent as a reply.

- By default, `github-review` does not allow you to move back and forth the diff
buffer and the actual source code.
You can define a list of projects and the respective directory location to
enable `diff-goto-source` (bound to `C-c c-c` by default) e.g.:
```elisp
(setq github-review-projects-worktree
'(("charignon/github-review". "~/.doom.d/sources/github-review")
("magit/forge" . "~/code/oss/magit-forge")))
```

## Notice

*I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my
Expand Down
13 changes: 12 additions & 1 deletion github-review.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
"Flag to enable displaying outdated comments in code lines."
:group 'github-review)

(defcustom github-review-projects-worktree ()
"Define directory path for your projects to be used by `diff-goto-source'. ")

(defconst github-review-diffheader '(("Accept" . "application/vnd.github.v3.diff"))
"Header for requesting diffs from GitHub.")

Expand Down Expand Up @@ -329,7 +332,15 @@ ACC is an alist accumulating parsing state."
(erase-buffer)
(insert diff)
(save-buffer)
(github-review-mode)))
(github-review-mode)

;; Use `C-c C-c' in diff-mode to go to source code
(when-let ((repo-path (alist-get
(format "%s/%s" .owner .repo)
github-review-projects-worktree
nil nil 'equal)))
(setq diff-remembered-defdir repo-path)
(setq default-directory repo-path))))

(defun github-review-parsed-review-from-current-buffer ()
"Return a code review given the current buffer containing a diff."
Expand Down

0 comments on commit 65975c2

Please sign in to comment.