Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set the reference commit for the branch list #82

Merged
merged 4 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Activate =magit-todos-mode=. Then open a Magit status buffer, or run ~magit-tod
*** 1.3-pre

*Added*
+ Branch diff task list. See new option =magit-todos-show-branch-list=, and command =magit-todos-toggle-branch-list=, bound to =b= with point on to-do list heading. ([[https://github.com/alphapapa/magit-todos/issues/30][#30]], [[https://github.com/alphapapa/magit-todos/issues/77][#77]]. Thanks to [[https://github.com/itamarst][Itamar Turner-Trauring]] and [[https://github.com/arronmabrey][Arron Mabrey]] for the suggestion.)
+ Branch diff task list. See new options =magit-todos-show-branch-list= and =magit-todos-branch-list-commit-ref=, and command =magit-todos-branch-list-toggle=, bound to =b= with point on to-do list heading. ([[https://github.com/alphapapa/magit-todos/issues/30][#30]], [[https://github.com/alphapapa/magit-todos/issues/77][#77]], [[https://github.com/alphapapa/magit-todos/pull/82][#82]]. Thanks to [[https://github.com/itamarst][Itamar Turner-Trauring]] and [[https://github.com/arronmabrey][Arron Mabrey]] for the suggestion, and to [[https://github.com/smaret][Sébastien Maret]] for implementing the commit-ref option.)

*Internal*
+ Put newline in section headings. ([[https://github.com/alphapapa/magit-todos/pull/68][#68]]. Thanks to [[https://github.com/vermiculus][Sean Allred]].)
Expand Down
23 changes: 17 additions & 6 deletions magit-todos.el
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,18 @@ used."
(defcustom magit-todos-show-branch-list 'branch
"Show branch diff to-do list.
In the master branch, this shows whatever items are listed by
\"git diff HEAD^\".
\"git diff magit-todos-branch-list-commit-ref\".

This can be toggled locally in Magit buffers with command
`magit-todos-toggle-branch-list'."
:type '(choice (const :tag "Never" nil)
(const :tag "In non-master branches" branch)
(const :tag "Always" t)))

(defcustom magit-todos-branch-list-commit-ref '"HEAD^"
"Commit ref passed to \"git diff\" command used to make branch diff list."
:type 'string)

;;;; Commands

;;;###autoload
Expand Down Expand Up @@ -579,8 +583,12 @@ See `magit-section-match'. Also delete it from root section's children."
(object-remove-from-list magit-root-section 'children section)
(with-slots (start end) section
;; NOTE: We delete 1 past the end because we insert a newline after the section. I'm not
;; sure if this would generalize to all Magit sections.
(delete-region start (1+ end))))))
;; sure if this would generalize to all Magit sections. But if the end is the same as
;; `point-max', which may be the case if todo items have not yet been inserted, we only
;; delete up to `point-max'.
(delete-region start (if (= end (point-max))
end
(1+ end)))))))

(defun magit-todos--item-buffer (item)
"Return buffer visiting ITEM."
Expand Down Expand Up @@ -1182,7 +1190,7 @@ MAGIT-STATUS-BUFFER is what it says. DIRECTORY is the directory in which to run

(magit-todos-defscanner "rg"
:test (executable-find "rg")
:command (list "rg" "--no-heading"
:command (list "rg" "--no-heading" "--line-number"
(when depth
(list "--maxdepth" (1+ depth)))
(when magit-todos-ignore-case
Expand Down Expand Up @@ -1211,8 +1219,11 @@ MAGIT-STATUS-BUFFER is what it says. DIRECTORY is the directory in which to run
;; NOTE: This scanner implements the regexp *searching* in elisp rather than in the
;; external process because, unlike "git grep", "git diff" does not support PCRE.
:test t
:command (list "git" "--no-pager" "diff" "--no-color" "-U0" "HEAD^")
:callback #'magit-todos--git-diff-callback)
:command (progn
;; Silence byte-compiler warnings about these vars we don't use in this scanner.
(ignore search-regexp-elisp search-regexp-pcre extra-args directory depth)
(list "git" "--no-pager" "diff" "--no-color" "-U0" "HEAD^"))
:callback 'magit-todos--git-diff-callback)

(magit-todos-defscanner "find|grep"
;; NOTE: The filenames output by find|grep have a leading "./". I don't expect this scanner to be
Expand Down