summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-04-16 23:14:29 -0400
committerKyle Meyer <kyle@kyleam.com>2020-04-16 23:54:15 -0400
commitc13260a31901641b022e97bc194c6a7d0e54ff8e (patch)
treee1d597d5b61cf494cd7dbc6c490cfa041badca8b /lisp
parentc845edda271f5ad76f1fe32da5c37fc6dde4815b (diff)
downloademacs.d-c13260a31901641b022e97bc194c6a7d0e54ff8e.tar.gz
km/magit-copy-commit-summary: Strip trailing period
Trailing periods in commit message subjects are especially annoying when using the reference format within a paragraph.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/km-magit.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index a112099..c8b855a 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -837,13 +837,20 @@ COMMIT."
(list (or (and (not current-prefix-arg) atpoint)
(magit-read-branch-or-commit "Commit" atpoint)))))
(if (magit-rev-verify (concat commit "^{commit}"))
- (kill-new (message
- "%s"
- ;; Using `magit-git-string' instead of
- ;; `magit-rev-format' to pass --date flag.
- (magit-git-string "show" "-s" "--date=short"
- "--format=reference"
- commit "--")))
+ (kill-new
+ (message
+ "%s"
+ (replace-regexp-in-string
+ ;; Drop trailing period, if any, from the subject.
+ (rx (group ".") ", "
+ (repeat 4 digit) "-" (repeat 2 digit) "-" (repeat 2 digit)
+ ")" string-end)
+ ""
+ ;; Using `magit-git-string' instead of `magit-rev-format' to
+ ;; pass --date flag.
+ (magit-git-string "show" "-s" "--date=short" "--format=reference"
+ commit "--")
+ t t 1)))
(user-error "%s does not exist" commit)))
(defun km/magit-copy-commit-summary-from-header (&optional _)