diff options
| author | Christoph Badura | 2025-01-26 22:48:11 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-03-09 14:28:25 +0800 |
| commit | 00e284fc52b44fc3cb435a5d17ce58af1b753a34 (patch) | |
| tree | 510aa7a4504f2782efd5b3746eb5c67267abaa0b /test | |
| parent | 4db604f3751ffb6a1fc3fd4277445a8f94cec13f (diff) | |
| download | emacs-00e284fc52b44fc3cb435a5d17ce58af1b753a34.tar.gz emacs-00e284fc52b44fc3cb435a5d17ce58af1b753a34.zip | |
VC: New hook to strip CVS template lines when committing
Add a hook function to strip all lines beginning with "CVS:" from the
commit message as CVS does. Do this only if 'log-edit-vc-backend' is
'CVS'. (Bug#72341)
* lisp/vc/log-edit.el
(log-edit-done-strip-cvs-lines): New command.
(log-edit-done-hook): Add it as an option.
* test/lisp/vc/log-edit-tests.el
(log-edit-done-strip-cvs-lines-helper): New function.
(log-edit-done-strip-cvs-lines-cvs)
(log-edit-done-strip-cvs-lines-non-cvs)
(log-edit-done-strip-cvs-lines-only-cvs-colon-blank)
(log-edit-done-strip-cvs-lines-only-cvs-colon): New test cases.
* etc/NEWS: Mention log-edit-done-strip-cvs-lines.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/vc/log-edit-tests.el | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/lisp/vc/log-edit-tests.el b/test/lisp/vc/log-edit-tests.el index 005c336a3b6..6a312c6dac7 100644 --- a/test/lisp/vc/log-edit-tests.el +++ b/test/lisp/vc/log-edit-tests.el | |||
| @@ -360,4 +360,57 @@ Report color and/or grayscale properly. | |||
| 360 | (let ((fill-column 64)) (log-edit-fill-entry)) | 360 | (let ((fill-column 64)) (log-edit-fill-entry)) |
| 361 | (should (equal (buffer-string) wanted))))) | 361 | (should (equal (buffer-string) wanted))))) |
| 362 | 362 | ||
| 363 | (defun log-edit-done-strip-cvs-lines-helper (initial-text wanted vc-backend) | ||
| 364 | "Helper function for the log-edit-done-strip-cvs-lines tests. | ||
| 365 | Tests that running log-edit-done-strip-cvs-lines as a log-edit-done-hook | ||
| 366 | produces the WANTED string when run on INITIAL-TEXT with | ||
| 367 | 'log-edit-vc-backend' set to VC-BACKEND.\"" | ||
| 368 | (with-temp-buffer | ||
| 369 | (let ((log-edit-done-hook 'log-edit-done-strip-cvs-lines) | ||
| 370 | (log-edit-vc-backend vc-backend)) | ||
| 371 | (setq-local log-edit-callback #'(lambda () (interactive) nil)) | ||
| 372 | (insert initial-text) | ||
| 373 | (log-edit-done) | ||
| 374 | (should (equal (buffer-string) wanted))))) | ||
| 375 | |||
| 376 | (ert-deftest log-edit-done-strip-cvs-lines-cvs () | ||
| 377 | "Strip lines beginning with \"CVS:\" when using CVS as VC backend." | ||
| 378 | (let (string wanted) | ||
| 379 | (setq string "summary line | ||
| 380 | first line | ||
| 381 | CVS: Please evaluate your changes and consider the following. | ||
| 382 | CVS: Abort checkin if you answer no. | ||
| 383 | " | ||
| 384 | wanted "summary line | ||
| 385 | first line | ||
| 386 | ") | ||
| 387 | (log-edit-done-strip-cvs-lines-helper string wanted 'CVS))) | ||
| 388 | |||
| 389 | (ert-deftest log-edit-done-strip-cvs-lines-non-cvs () | ||
| 390 | "Do not strip lines beginning with \"CVS:\" when not using CVS as VC backend." | ||
| 391 | (let (string) | ||
| 392 | (setq string "summary line | ||
| 393 | first line | ||
| 394 | CVS: Please evaluate your changes and consider the following. | ||
| 395 | CVS: Abort checkin if you answer no. | ||
| 396 | ") | ||
| 397 | (log-edit-done-strip-cvs-lines-helper string string nil))) | ||
| 398 | |||
| 399 | (ert-deftest log-edit-done-strip-cvs-lines-only-cvs-colon-blank () | ||
| 400 | "Strip lines that contain solely \"CVS: \" when using CVS as VC backend." | ||
| 401 | (let (string wanted) | ||
| 402 | (setq string "CVS: \n" | ||
| 403 | wanted "") | ||
| 404 | (log-edit-done-strip-cvs-lines-helper string wanted 'CVS))) | ||
| 405 | |||
| 406 | (ert-deftest log-edit-done-strip-cvs-lines-only-cvs-colon () | ||
| 407 | "Strip lines that contain solely \"CVS:\" when using CVS as VC backend." | ||
| 408 | ;; This test verifies that lines consisting only of "CVS:" (no blank | ||
| 409 | ;; after the colon) are stripped from the commit message. | ||
| 410 | ;; CVS does this to accomodate editors that delete trailing whitespace. | ||
| 411 | (let (string wanted) | ||
| 412 | (setq string "CVS:\n" | ||
| 413 | wanted "") | ||
| 414 | (log-edit-done-strip-cvs-lines-helper string wanted 'CVS))) | ||
| 415 | |||
| 363 | ;;; log-edit-tests.el ends here | 416 | ;;; log-edit-tests.el ends here |