Add function to generate commit messages with gptel
This commit is contained in:
parent
0b8be7b2f7
commit
bcb8d468a6
@ -21,6 +21,26 @@
|
||||
(embark-general-map
|
||||
"?" #'gptel-quick))
|
||||
|
||||
(defun gptel-commit-message ()
|
||||
"Generate a commit message via gptel."
|
||||
(interactive)
|
||||
(unless git-commit-mode
|
||||
(user-error "Not in a git commit buffer!"))
|
||||
(let* ((diff-buf (magit-get-mode-buffer 'magit-diff-mode))
|
||||
(diff (with-current-buffer diff-buf
|
||||
(buffer-substring-no-properties
|
||||
(point-min)
|
||||
;; Skip the last line, which is just the [back] button
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(forward-line -1)
|
||||
(point)))))
|
||||
(prompt (format "%s\n\nWrite a clear, concise commit message for this diff. The first line should succinctly summarize the changes made and should be no more than 50 characters. If additional context is needed, include it in an additional paragraph separate by a blank line from the first line." diff)))
|
||||
(message "Generating commit message...")
|
||||
(gptel-request prompt
|
||||
:stream t
|
||||
:system "You are an experienced software engineer writing a commit message.")))
|
||||
|
||||
(use-package llama
|
||||
:straight `(:local-repo ,(expand-file-name "packages/llama" user-emacs-directory) :type nil)
|
||||
:load-path "packages/llama"
|
||||
|
Loading…
Reference in New Issue
Block a user