Skip to content

Commit

Permalink
Change: (magit-todos-branch-list-merge-base-ref) Detect automatically
Browse files Browse the repository at this point in the history
Fixes #151.  Closes #152.

Reported-by: Aaron Zeng <https://github.com/bcc32>
  • Loading branch information
alphapapa committed Aug 26, 2023
1 parent 8f22fa5 commit 8efc64a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Helm and Ivy are also supported. Note that the =helm= and =ivy= packages are no

*Changed*
+ Improve behavior when scanner backend exits with an error. (Now an error is signaled and the command's output is shown.)
+ Option ~magit-todos-branch-list-merge-base-ref~ defaults to nil, which automatically detects the default branch name using function ~magit-main-branch~. ([[https://github.com/alphapapa/magit-todos/issues/151][#151]]. Thanks to [[https://github.com/bcc32][Aaron Zeng]] for reporting.)

*Fixed*
+ Updated ~find|grep~ scanner for newer versions of GNU ~find~ that interpret some arguments differently. (Tested on v4.8.0.)
Expand Down
11 changes: 7 additions & 4 deletions magit-todos.el
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ This can be toggled locally in Magit buffers with command
(const :tag "In non-master branches" branch)
(const :tag "Always" t)))

(defcustom magit-todos-branch-list-merge-base-ref "master"
(defcustom magit-todos-branch-list-merge-base-ref nil
"Commit ref passed to command \"git merge-base HEAD\".
Determines the ancestor commit from which the current branch's
todos should be searched for. May be overridden in the case that
Expand All @@ -387,7 +387,8 @@ By default, the branch todo list would show todos from both the
\"topic\" branch and the \"topic2\" branch. To show only todos
from the \"topic2\" branch, this option could be set to
\"topic\"."
:type 'string)
:type '(choice (const :tag "Automatic" :doc "Value returned by `magit-main-branch'" nil)
(string :tag "Specified branch name")))

(defcustom magit-todos-submodule-list nil
"Show submodule to-do list."
Expand Down Expand Up @@ -760,12 +761,14 @@ This function should be called from inside a ‘magit-status’ buffer."
(magit-todos--insert-items (current-buffer) magit-todos-item-cache)))
(when (or (eq magit-todos-branch-list t)
(and (eq magit-todos-branch-list 'branch)
(not (string= "master" (magit-get-current-branch)))))
(not (equal (or magit-todos-branch-list-merge-base-ref (magit-main-branch))
(magit-get-current-branch)))))
;; Insert branch-local items.
(magit-todos--scan-with-git-diff :magit-status-buffer (current-buffer)
:directory default-directory
:depth magit-todos-depth
:heading (format "TODOs (branched from %s)" magit-todos-branch-list-merge-base-ref))))
:heading (format "TODOs (branched from %s)"
(or magit-todos-branch-list-merge-base-ref (magit-main-branch))))))

(cl-defun magit-todos--insert-items (magit-status-buffer items &key branch-p)
"Insert to-do ITEMS into MAGIT-STATUS-BUFFER.
Expand Down

0 comments on commit 8efc64a

Please sign in to comment.