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

Empy commit message being passed to git #13

Open
martinbaillie opened this issue Dec 4, 2024 · 2 comments
Open

Empy commit message being passed to git #13

martinbaillie opened this issue Dec 4, 2024 · 2 comments

Comments

@martinbaillie
Copy link

Thanks for the neat package. I was looking for something just like this 👍🏻

I've just had a quick play (latest version) and I'm not sure if its PEBKAC or what, but despite a COMMIT_MSG buffer looking great, complete with generated content, a typical C-CC-c to commit in Magit is resulting in "Aborting commit due to empty commit message".

This is regardless of the way I have generated the message using magit-gptcommit.

If I override magit-gptcommit-commit-accept to add (save-buffer) at the end then it works but that feels heavyweight and that it might mess up some other stuff. I naively tried things like (set-buffer-modified-p t) instead but they didn't work.

Again, feels like a me problem but if you have time I'd appreciate some pointers on what to look for.

@douo
Copy link
Owner

douo commented Dec 5, 2024

This sounds a bit strange, but I couldn’t reproduce it in my environment. Also, the BUFFER name is COMMIT_EDITMSG, not COMMIT_MSG in my environment.

@martinbaillie
Copy link
Author

the BUFFER name is COMMIT_EDITMSG, not COMMIT_MSG in my environment

Ah yes, mine too. I didn't pay enough attention when writing this issue.

Sounds like a me problem then. I could only make it work with some advising:

(advice-add 'magit-gptcommit-commit-accept :after
            (lambda ()
              (when-let ((buf (magit-commit-message-buffer)))
                (with-current-buffer buf
                  (save-buffer)))))

I notice if I run the magitgpt-accept function again whilst in the COMMIT_EDITMSG buffer (so already after doing c then C from the magit-status transient menu) then it works. Would you expect the user to have to do it twice?

I can reproduce with this slimline config:

(require 'use-package)
(setq auth-sources '((:source "REDACTED")))
(use-package magit)
(use-package dash)
(use-package llm :custom (llm-warn-on-nonfree nil))
(use-package magit-gptcommit
  :demand t
  :after magit
  :init
  (require 'llm-openai)

  :custom
  (magit-gptcommit-llm-provider
   (make-llm-openai
    :key (auth-source-pick-first-password :host "api.openai.com" :user "REDACTED")
    :chat-model "gpt-4o"))

  :config
  (magit-gptcommit-status-buffer-setup)
  (magit-gptcommit-mode 1))

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

No branches or pull requests

2 participants