From 5e93926f172dda15e0f4cddcb3dcfe55b1e426ba Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Fri, 25 Sep 2020 17:05:10 +0200 Subject: Simplify revision-formatting function Commit 2020-09-25 "* CONTRIBUTE: Don't recommend action stamps" (499848d840) officially disavows action stamps. --- .emacs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/.emacs b/.emacs index 773af2f..d62e7ef 100644 --- a/.emacs +++ b/.emacs @@ -260,28 +260,21 @@ ((derived-mode-p 'magit-mode) (magit-branch-or-commit-at-point)))) -(eval-when-compile - ;; Load rx's pcase pattern. - (require 'rx)) - -(defun my/action-stamp-at-point (rev) +(defun my/describe-revision (rev) + "Format a Git revision in a format suitable for changelogs." (interactive (list (let* ((rev (my/revision-at-point)) - (prompt (if rev (format "Revision? (%s) " rev) "Revision? "))) + (prompt (format-prompt "Revision" rev))) (read-string prompt nil nil rev)))) - (let* ((cmd "git show --no-patch --date=unix --format='%ad!%ae'") - (git-info (shell-command-to-string (format "%s %s" cmd rev)))) - (pcase git-info - ((rx (let timestamp-str (+ digit)) - "!" - (let mail (+ anychar)) - "\n") - (let* ((timestamp (string-to-number timestamp-str)) - (date (format-time-string "%FT%TZ" timestamp t)) - (action-stamp (format "%s!%s" date mail))) - (kill-new action-stamp) - (message action-stamp)))))) + (let* ((rev-fmt "%cd \"%s\" (%h)") + (desc + (string-trim + (shell-command-to-string + (format "git show --no-patch --date=short --format='%s' %s" + rev-fmt rev))))) + (kill-new desc) + (message desc))) ;; Major modes configuration -- cgit v1.2.3