magit/forge

Provide a replacement for `forge-insert-assigned-issues` (among others)

sergiodj opened this issue · 7 comments

Hi,

I have the following definition on my init.el:

(use-package forge
  :after magit
  :config
  (magit-add-section-hook 'magit-status-sections-hook
			  #'forge-insert-assigned-issues
			  #'forge-insert-issues t))

This is now giving me a warning message:

‘magit-status-sections-hook’ contains entries that are no longer valid.
 `forge-insert-assigned-issues'

It started today after I upgraded my packages; I'm using forge 20240623.1337 (which arguably is not expected to be as stable, but I thought I'd file this bug anyway). I believe there should be an update to the docs explaining how to replace these retired functions.

Thanks!

I haven't updated the documentation yet, but will do so soon.

I have removed the functions that insert a particular selection of topics. There are now many more filtering options and you can use more than one filter at once. As a result it isn't feasible anymore, to provide a dedicated inserter function for each filter (combination).

See #673 for how to set a filter.

Ah, thanks, I failed to see the other issue.

It seems to me that it's not possible anymore to create multiple sections in the magit-status-mode buffer? For example, if I want to list all open issues and all issues assigned to me, is it possible to do so? I tried something like:

(setq forge-status-buffer-default-topic-filters
         `(,(forge--topics-spec :type 'topic :active t :state 'open :order 'newest)
           ,(forge--topics-spec :type 'issue :active t :state 'open :order 'newest :assignee "mynick")))

but it didn't work.

Thanks.

I had faint hope that users wouldn't miss these functions after getting used to the new quicker and more flexible filtering, which is why I initially didn't provide instructions on how to bring them back.

Now that I have looked into it again, and made some minor tweaks (f09d222), you can define this command like so:

  (defun forge-insert-assigned-issues ()
    "Insert a list of issues that are assigned to you.
  Mostly honor the buffer's filtering spec, overriding
  only the `assignee' slot."
    (when-let (((forge-db t))
               (repo (forge-get-repository :tracked?))
               (user (ghub--username repo))
               (spec (clone forge--buffer-topics-spec)))
      (oset spec assignee user)
      (forge-insert-issues spec "Assigned issues")))

To re-implement related removed functions, see the commit that removed them de31e7c (which made
4823eb3 possible). Converting these functions should work much the same as it did for forge-insert-assigned-issues.


I imagine you want this feature because you are approximately in this situation: You contribute to a project with many issues and contributors, and most of the time you are only interested in the topics that have been assigned to you. However, occasionally you to look at the new topics, e.g., to determine which you have to take responsibility for.

If that were my situation, I would (oset forge-status-buffer-default-topic-filters assignee "tarsius") and then, when I actually am temporarily interested in seeing all active topics, I would C-c C-c to list them in a separate buffer, without having to all the time make every refresh of the status buffer (slightly) more expensive, and the buffer (slightly) more noisy.

Thank you very much for the extra details.

You're right that the project I contribute to has many issues and contributors. More often than not, the issues are created without an assignee and I have to review them and choose what I will work on next, so in my case it makes sense to just leave the default almost as is (just adjusting the order parameter to recently-updated), and then filtering the issues by assignee if needed.

Either way, I noticed that you've added some code to make things easier to add new sections. That's also much appreciated.

Thanks.

Overall I like the idea of how the new filtering mechanism works, though I wonder if it is possible to filter out some items (e.g. PRs) based on some words/pattern within the title? while on monorepos not all PRs are relevant to me and would be nice to exclude these or those opened by automated tools to reduce noise.

I plan to add more filters and search, but not before the release and I probably won't jump to do it right after the release either. But its definitely something I want to do eventually.

I've added a new function forge-insert-topics to make it easier to define topic list insertion functions. Please consult it's fairly detailed docstring, and use it like so:

(defun my-forge-insert-assigned-issues ()
  "Insert a list of issues that are assigned to you.
Mostly honor the buffer's filtering spec, overriding only the `type' and
`assignee' slots."
  ;; Move any work you are tempted to do here ...
  (forge-insert-topics 'assigned-issues "Assigned issues"
    (lambda (repo)
      ;;; ... to here instead.  For example ----,
      (and-let* ((me (ghub--username repo))) ;<-'
        (forge--topics-spec :type 'issue :active t :assignee me)))))

(magit-add-section-hook 'magit-status-sections-hook
                        #'my-forge-insert-assigned-issues
                        #'forge-insert-issues)