From 4b549f8a1fc119dc462f4dc214e502302490697a Mon Sep 17 00:00:00 2001 From: John Doty Date: Mon, 26 May 2025 07:42:44 -0700 Subject: [PATCH] [emacs] Fix the project root tool --- site-lisp/doty-tools.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/site-lisp/doty-tools.el b/site-lisp/doty-tools.el index 4ed002f..27157bd 100644 --- a/site-lisp/doty-tools.el +++ b/site-lisp/doty-tools.el @@ -523,13 +523,26 @@ Returns file path, modified status, major mode, size, line count, and more." (gptel-make-tool :name "get_project_root" - :function #'project-root + :function #'doty-tools--get-project-root :description "Get the root directory of the current project." :args () :category "reading" :confirm nil :include t) +(ert-deftest doty-tools--test--get_project_root () + "Tests for the emacs_insert_line tool." + (let* ((tf (make-temp-file "test-project-" t))) + (unwind-protect + (with-temp-buffer + (let ((default-directory tf)) + (call-process "git" nil t nil "init" ".") + (should + (equal (file-name-as-directory tf) + (doty-tools--test--invoke-tool "get_project_root" ()))))) + + (delete-directory tf t)))) + (defun doty-tools--search-project-regex (callback regex) "Search the current project for instances of a given REGEX.