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

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

[elpa] externals/agitate 8c7ff17ec3 1/2: Add agitate-vc-git-show-tag com


From: ELPA Syncer
Subject: [elpa] externals/agitate 8c7ff17ec3 1/2: Add agitate-vc-git-show-tag command
Date: Fri, 30 Sep 2022 23:57:15 -0400 (EDT)

branch: externals/agitate
commit 8c7ff17ec3a4e00d7f7c60766cdee656792dacf4
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add agitate-vc-git-show-tag command
---
 README.org |  4 ++++
 agitate.el | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/README.org b/README.org
index fea2f4d7a9..661e6a6bd9 100644
--- a/README.org
+++ b/README.org
@@ -161,6 +161,10 @@ commits" are documented here: 
<https://www.conventionalcommits.org/en/v1.0.0/>.
   completion candidates is limited to the value of
   ~vc-log-show-limit~.
 
+#+findex: agitate-vc-git-show-tag
++ ~agitate-vc-git-show-tag~ :: Run =git-show(1)= on Git =TAG=.  When
+  called interactively, prompt for TAG using minibuffer completion.
+
 #+findex: agitate-vc-git-format-patch-single
 + ~agitate-vc-git-format-patch-single~ :: Format patch for a single
   =COMMIT=.  If in a log-view buffer, the =COMMIT= is the one at
diff --git a/agitate.el b/agitate.el
index 23109c7941..3b9a03cf45 100644
--- a/agitate.el
+++ b/agitate.el
@@ -346,6 +346,38 @@ The number of completion candidates is limited to the 
value of
                         (goto-char (point-min)))))
         (goto-char (point-min))))))
 
+(defun agitate--vc-git-tag-prompt ()
+  "Prompt for Git tag."
+  (when-let* ((default-directory (vc-root-dir)))
+    (completing-read
+     "Select tag: "
+     (agitate--completion-table-no-sort
+      (process-lines
+       vc-git-program "tag"
+       "--"))
+     nil t)))
+
+;;;###autoload
+(defun agitate-vc-git-show-tag (tag)
+  "Run `git-show(1)' on Git TAG.
+When called interactively, prompt for TAG using minibuffer
+completion."
+  (interactive (list (agitate--vc-git-tag-prompt)))
+  (let* ((buf "*agitate-vc-git-show*")
+         (args (list "show" tag)))
+    (apply 'vc-git-command (get-buffer-create buf) nil nil args)
+    ;; TODO 2022-09-27: What else do we need to set up in such a
+    ;; buffer?
+    (with-current-buffer (pop-to-buffer buf)
+      (diff-mode)
+      (setq-local revert-buffer-function
+                  (lambda (_ignore-auto _noconfirm)
+                    (let ((inhibit-read-only t))
+                      (erase-buffer)
+                      (apply 'vc-git-command (get-buffer buf) nil nil args)
+                      (goto-char (point-min)))))
+      (goto-char (point-min)))))
+
 (defun agitate--vc-git-format-patch-single-commit ()
   "Help `agitate-vc-git-format-patch-single' with its COMMIT."
   (if-let ((default-value (cadr (log-view-current-entry (point) t))))



reply via email to

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