Skip to content

Conversation

@ahmed-shariff
Copy link

This PR merges the separated gptel branch with the main branch. To support both llm and gptel, this also adds a customizable variable magit-gptcommit-backend which is expected to be either llm or gptel. It also removes the respective require calls, as this would expect the user to have one of the packages configured (see magit-gptcommit--ensure-backend-loaded). I have also updated the readme accordingly. Let me know what you think.

Note: to keep up with the main branch, I had been cherry-picking commits and applying them to a branch maintained in my fork. Hence why the merge history shows some of the commits already merged to master.

@ahmed-shariff
Copy link
Author

I have tested this with gptel and it works as expected. I haven't configured llm, and I am not familiar with how it works. It'd be nice if someone could test that.

@ahmed-shariff
Copy link
Author

Forced pushed with a cleaner history and minor cleanup

@LemonBreezes
Copy link
Collaborator

Before merging this one I would like for #28 to be reviewed since it's such a huge change that fixes critical bugs.

@jiacai2050
Copy link

Any luck on this?

@LemonBreezes
Copy link
Collaborator

Any luck on this?

It works perfectly for me and @douo hasn't followed up. Please check it out and post what you think. I may merge it if you don't encounter any issues.

@jiacai2050
Copy link

Thanks for you quick response, I will try this PR on my machine.

@LemonBreezes
Copy link
Collaborator

Thanks for you quick response, I will try this PR on my machine.

Oh my bad! I thought this was a comment for the other PR.

@ahmed-shariff ahmed-shariff mentioned this pull request Apr 21, 2025
@jiacai2050
Copy link

Oh my bad! I thought this was a comment for the other PR.

Aha, no concerns, I'll proceed with this PR nonetheless.

The douo#28 PR introduces some new functions and adds extensive
debugging. Move the common function and adding appropriate debug calls
within gptel functions as well.
@ahmed-shariff
Copy link
Author

Before merging, can you guys check if this works as intended?

@jiacai2050
Copy link

(use-package magit-gptcommit
  :load-path "~/misc/magit-gptcommit/"
  :bind (:map git-commit-mode-map
         ("C-c C-g" . magit-gptcommit-commit-accept))
  :commands (magit-gptcommit-generate)
  :custom
  (magit-gptcommit-backend 'gptel)

  :hook (magit-status-mode . 'my/enable-gptcommit)
  :init
  (defun my/enable-gptcommit ()
    (interactive)
    (magit-gptcommit-mode 1)
    (magit-gptcommit-status-buffer-setup)))

This is config I tested, and this PR works totally fine for me!

Require gptel-request and introduce a local handler alist so
magit-gptcommit can merge its custom gptel handlers with the handlers
provided by the gptel-request module. Instead of hardcoding the
handler list, compute the unique set of handler keys from both alists
and assemble a combined handler entry for each key, preserving
magit-specific handlers while reusing gptel-request handlers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants