emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ellama 23bcd19613 6/7: Merge pull request #141 from s-k


From: ELPA Syncer
Subject: [elpa] externals/ellama 23bcd19613 6/7: Merge pull request #141 from s-kostyaev/add-commit-message-generation
Date: Wed, 10 Jul 2024 15:58:18 -0400 (EDT)

branch: externals/ellama
commit 23bcd19613b6c1da3374790d7db7b7c108a962f2
Merge: d32e76c1f2 7528e4346e
Author: Sergey Kostyaev <s-kostyaev@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #141 from s-kostyaev/add-commit-message-generation
    
    Add commit message generation
---
 .github/workflows/melpa.yml |  1 +
 ellama.el                   | 35 ++++++++++++++++++++++++++++++++++-
 tests/test-ellama.el        |  3 +--
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/melpa.yml b/.github/workflows/melpa.yml
index 73314abfc2..4b61dce6a5 100644
--- a/.github/workflows/melpa.yml
+++ b/.github/workflows/melpa.yml
@@ -26,6 +26,7 @@ jobs:
           - 29.1
           - 29.2
           - 29.3
+          - 29.4
         ignore_warnings:
           - false
         warnings_as_errors:
diff --git a/ellama.el b/ellama.el
index 609d6ce46e..ebae39c0d6 100644
--- a/ellama.el
+++ b/ellama.el
@@ -5,7 +5,7 @@
 ;; Author: Sergey Kostyaev <sskostyaev@gmail.com>
 ;; URL: http://github.com/s-kostyaev/ellama
 ;; Keywords: help local tools
-;; Package-Requires: ((emacs "28.1") (llm "0.6.0") (spinner "1.7.4"))
+;; Package-Requires: ((emacs "28.1") (llm "0.6.0") (spinner "1.7.4") (compat 
"29.1"))
 ;; Version: 0.11.6
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;; Created: 8th Oct 2023
@@ -42,6 +42,8 @@
 (require 'info)
 (require 'shr)
 (require 'eww)
+(require 'vc)
+(require 'compat)
 (eval-when-compile (require 'rx))
 
 (defgroup ellama nil
@@ -266,6 +268,17 @@ PROMPT is a prompt string."
   :group 'ellama
   :type 'string)
 
+(defcustom ellama-generate-commit-message-template "You are professional 
software developer.
+Write concise commit message based on diff. First line should
+contain short title described major change in functionality. Then
+one empty line. Then detailed description of all changes. Reply
+with commit message only. Diff:
+
+%s"
+  "Prompt template for `ellama-generate-commit-message'."
+  :group 'ellama
+  :type 'string)
+
 (defcustom ellama-make-format-prompt-template "Render the following text as a 
%s:\n%s"
   "Prompt template for `ellama-make-format'."
   :group 'ellama
@@ -1626,6 +1639,26 @@ the full response text when the request completes (with 
BUFFER current)."
         (text (buffer-substring-no-properties beg end)))
     (ellama-stream text)))
 
+;;;###autoload
+(defun ellama-generate-commit-message ()
+  "Generate commit message based on diff."
+  (interactive)
+  (let* ((default-directory
+         (if (string= ".git"
+                      (car (reverse
+                            (cl-remove
+                             ""
+                             (file-name-split default-directory)
+                             :test #'string=))))
+             (file-name-parent-directory default-directory)
+           default-directory))
+        (diff (with-temp-buffer
+                (vc-diff-internal
+                 nil (vc-deduce-fileset t) nil nil nil (current-buffer))
+                (buffer-substring-no-properties (point-min) (point-max)))))
+    (ellama-stream
+     (format ellama-generate-commit-message-template diff))))
+
 ;;;###autoload
 (defun ellama-ask-line ()
   "Send current line to ellama chat."
diff --git a/tests/test-ellama.el b/tests/test-ellama.el
index e102da4813..5c430ae6b1 100644
--- a/tests/test-ellama.el
+++ b/tests/test-ellama.el
@@ -1,9 +1,8 @@
-;;; test-ellama.el --- Ellama tests -*- lexical-binding: t -*-
+;;; test-ellama.el --- Ellama tests -*- lexical-binding: t; 
package-lint-main-file: "../ellama.el"; -*-
 
 ;; Copyright (C) 2023  Free Software Foundation, Inc.
 
 ;; Author: Sergey Kostyaev <sskostyaev@gmail.com>
-;; Package-Requires: ((emacs "28.1") (llm "0.6.0") (spinner "1.7.4"))
 
 ;; This file is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by



reply via email to

[Prev in Thread] Current Thread [Next in Thread]