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

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

Closed
sergiodj opened this issue Jun 26, 2024 · 7 comments
Closed
Labels
support User needs some help

Comments

@sergiodj
Copy link

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!

@tarsius
Copy link
Member

tarsius commented Jun 26, 2024

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.

@tarsius tarsius pinned this issue Jun 26, 2024
@tarsius tarsius added the support User needs some help label Jun 26, 2024
@tarsius tarsius closed this as completed Jun 26, 2024
@sergiodj
Copy link
Author

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.

@tarsius
Copy link
Member

tarsius commented Jun 27, 2024

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.

tarsius added a commit that referenced this issue Jun 27, 2024
This allows wrapping these functions, while overriding certain aspects,
to define additional section inserters that apply additional filtering.

In `forge--insert-topics' use the heading as the "value", which is
necessary to tell different sections apart.

See #676.  Usage example:

  (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")))

  (magit-add-section-hook 'magit-status-sections-hook
                          #'forge-insert-assigned-issues
                          #'forge-insert-issues t)
@sergiodj
Copy link
Author

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.

@zzantares
Copy link

zzantares commented Jul 9, 2024

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.

@tarsius
Copy link
Member

tarsius commented Jul 10, 2024

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.

tarsius added a commit that referenced this issue Jul 26, 2024
@tarsius
Copy link
Member

tarsius commented Jul 26, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User needs some help
Projects
None yet
Development

No branches or pull requests

3 participants