From 65975c2c933d82e52803c4d0a5f940509f7ff9a6 Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 13:27:42 -0300 Subject: [PATCH 01/11] enable goto-source code from diff buffer --- README.md | 18 ++++++++++++++++++ github-review.el | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 26446ab..a4d9d43 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/github-review.el b/github-review.el index 5a9c9e3..7504534 100644 --- a/github-review.el +++ b/github-review.el @@ -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.") @@ -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." From 42efb15b27ecb3c660c2a5301da429916420ed8c Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 16:15:58 -0300 Subject: [PATCH 02/11] fix ci? --- .github/workflows/ci.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abe6697..c67eacc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,15 @@ name: CI - -on: [push] - +on : [push] jobs: build: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Run CI in docker - run: docker run -v $(pwd):/opt silex/emacs:27.1-ci-cask bash -c "cd /opt && make ci" + - uses: actions/checkout@v1 + - uses: actions/setup-python@v2 + - uses: purcell/setup-emacs@master + with: + version: '27.1' + - uses: conao3/setup-cask@master + + - name: Run tests + run: make ci From 201079b0b1f4e5b1f8f0f0b8f3f295175c7dc924 Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 16:24:04 -0300 Subject: [PATCH 03/11] trigger on push or pull request events --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c67eacc..dd174e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ name: CI -on : [push] +on : [push, pull_request] jobs: build: runs-on: ubuntu-latest From f20757895a3256afd1c1220687014dc282e3397e Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 16:26:42 -0300 Subject: [PATCH 04/11] do not upgrade manually --- .github/workflows/ci.yml | 4 +++- makefile | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd174e8..e006fa6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,8 @@ jobs: with: version: '27.1' - uses: conao3/setup-cask@master + with: + version: 'snapshot' - name: Run tests - run: make ci + run: make test diff --git a/makefile b/makefile index 13db53c..d68ac22 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,4 @@ .PHONY: ci local test -ci: - cask upgrade-cask - cask install - cask exec buttercup -L test/github-review-test.el test: cask exec buttercup -L test/github-review-test.el From 44e6de5f35eec8cbcaa596d374df91df87458f82 Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 16:32:07 -0300 Subject: [PATCH 05/11] cask install --- makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile b/makefile index d68ac22..6fcdf55 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,7 @@ .PHONY: ci local test test: + cask install cask exec buttercup -L test/github-review-test.el # Run the tests locally From 1b41ff696d99e82a3bc6ef3975b4ee6d97aa402c Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 16:55:53 -0300 Subject: [PATCH 06/11] fix #31 --- github-review.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/github-review.el b/github-review.el index 5a9c9e3..f0108ee 100644 --- a/github-review.el +++ b/github-review.el @@ -505,10 +505,13 @@ Github API provides only the originalPosition in the query.") (interactive) (let* ((pullreq (or (forge-pullreq-at-point) (forge-current-topic))) (repo (forge-get-repository pullreq))) - (github-review-start-internal (a-alist 'owner (oref repo owner) - 'repo (oref repo name) - 'apihost (oref repo apihost) - 'num (oref pullreq number))))) + + (if (not (forge-pullreq-p pullreq)) + (message "We can only review PRs at the moment. You tried on something else.") + (github-review-start-internal (a-alist 'owner (oref repo owner) + 'repo (oref repo name) + 'apihost (oref repo apihost) + 'num (oref pullreq number)))))) ;;;###autoload (defun github-review-start (url) From 8aa7c4999c2d29fb59afe055e08a7afa1cb6abe7 Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 17:15:58 -0300 Subject: [PATCH 07/11] update based on issue #41 --- README.md | 12 ------------ github-review.el | 8 ++------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a4d9d43..2ce2872 100644 --- a/README.md +++ b/README.md @@ -133,18 +133,6 @@ configure the endpoint of your GitHub Enterprise installation, this should look 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 diff --git a/github-review.el b/github-review.el index 7504534..3051a08 100644 --- a/github-review.el +++ b/github-review.el @@ -335,12 +335,7 @@ ACC is an alist accumulating parsing state." (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)))) + (setq default-directory forge-current-dir))) (defun github-review-parsed-review-from-current-buffer () "Return a code review given the current buffer containing a diff." @@ -516,6 +511,7 @@ Github API provides only the originalPosition in the query.") (interactive) (let* ((pullreq (or (forge-pullreq-at-point) (forge-current-topic))) (repo (forge-get-repository pullreq))) + (setq forge-current-dir default-directory) (github-review-start-internal (a-alist 'owner (oref repo owner) 'repo (oref repo name) 'apihost (oref repo apihost) From 2260d70e7d6fb81bf98e0d1a21f9fcf5d1aa1369 Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 17:17:10 -0300 Subject: [PATCH 08/11] remove unnecessary code --- README.md | 6 ------ github-review.el | 3 --- 2 files changed, 9 deletions(-) diff --git a/README.md b/README.md index 2ce2872..26446ab 100644 --- a/README.md +++ b/README.md @@ -127,12 +127,6 @@ 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. - ## 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 diff --git a/github-review.el b/github-review.el index 3051a08..864cda5 100644 --- a/github-review.el +++ b/github-review.el @@ -68,9 +68,6 @@ "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.") From 6bebd41eec763541c2d2d9de762f2b6c97c7a450 Mon Sep 17 00:00:00 2001 From: Wanderson Ferreira Date: Sun, 10 Oct 2021 17:22:28 -0300 Subject: [PATCH 09/11] start at the beginning of the buffer --- github-review.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github-review.el b/github-review.el index 5a9c9e3..f70356d 100644 --- a/github-review.el +++ b/github-review.el @@ -329,7 +329,8 @@ ACC is an alist accumulating parsing state." (erase-buffer) (insert diff) (save-buffer) - (github-review-mode))) + (github-review-mode) + (goto-char (point-min)))) (defun github-review-parsed-review-from-current-buffer () "Return a code review given the current buffer containing a diff." From f0e556783fffe0ca5d5633b908a69135eac393c9 Mon Sep 17 00:00:00 2001 From: Laurent Charignon Date: Sun, 10 Oct 2021 14:57:53 -0700 Subject: [PATCH 10/11] Fix formatting --- github-review.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/github-review.el b/github-review.el index 0aeef8e..35b039e 100644 --- a/github-review.el +++ b/github-review.el @@ -508,14 +508,15 @@ Github API provides only the originalPosition in the query.") (interactive) (let* ((pullreq (or (forge-pullreq-at-point) (forge-current-topic))) (repo (forge-get-repository pullreq))) + (if (not (forge-pullreq-p pullreq)) (message "We can only review PRs at the moment. You tried on something else.") (progn (setq forge-current-dir default-directory) (github-review-start-internal (a-alist 'owner (oref repo owner) - 'repo (oref repo name) - 'apihost (oref repo apihost) - 'num (oref pullreq number))))))) + 'repo (oref repo name) + 'apihost (oref repo apihost) + 'num (oref pullreq number))))))) ;;;###autoload (defun github-review-start (url) From f138a83be6b0ef6017731182e7445af7057c4579 Mon Sep 17 00:00:00 2001 From: Laurent Charignon Date: Sun, 10 Oct 2021 14:59:01 -0700 Subject: [PATCH 11/11] Update github-review.el --- github-review.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/github-review.el b/github-review.el index 35b039e..fedaebe 100644 --- a/github-review.el +++ b/github-review.el @@ -508,15 +508,15 @@ Github API provides only the originalPosition in the query.") (interactive) (let* ((pullreq (or (forge-pullreq-at-point) (forge-current-topic))) (repo (forge-get-repository pullreq))) - + (if (not (forge-pullreq-p pullreq)) (message "We can only review PRs at the moment. You tried on something else.") - (progn - (setq forge-current-dir default-directory) - (github-review-start-internal (a-alist 'owner (oref repo owner) - 'repo (oref repo name) - 'apihost (oref repo apihost) - 'num (oref pullreq number))))))) + (progn + (setq forge-current-dir default-directory) + (github-review-start-internal (a-alist 'owner (oref repo owner) + 'repo (oref repo name) + 'apihost (oref repo apihost) + 'num (oref pullreq number))))))) ;;;###autoload (defun github-review-start (url)