Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
a7b59acea6 | |||
50cb58b11d | |||
97d9392d51 | |||
7b628c0ce0 | |||
a6b6e0fa18 |
3 changed files with 68 additions and 4 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
@ -10,6 +10,8 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
emacs_version:
|
emacs_version:
|
||||||
- '26.3'
|
- '26.3'
|
||||||
|
- '27.2'
|
||||||
|
- '28.2'
|
||||||
- 'snapshot'
|
- 'snapshot'
|
||||||
include:
|
include:
|
||||||
- emacs_version: 'snapshot'
|
- emacs_version: 'snapshot'
|
||||||
|
|
20
README.org
20
README.org
|
@ -114,3 +114,23 @@
|
||||||
A boolean value indicating whether to display the commit summary message,
|
A boolean value indicating whether to display the commit summary message,
|
||||||
which is usually displayed in the minibuffer. The default is ~nil~, meaning
|
which is usually displayed in the minibuffer. The default is ~nil~, meaning
|
||||||
that the summary would be displayed on every commit.
|
that the summary would be displayed on every commit.
|
||||||
|
|
||||||
|
|
||||||
|
To set any of these options, you can:
|
||||||
|
|
||||||
|
- Use the customization interface (~M-x customize-group git-auto-commit-mode~).
|
||||||
|
- Set the defaults in your Emacs initialization file using:
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(setq-default gac-ask-for-summary-p t)
|
||||||
|
#+end_src
|
||||||
|
- Set values in a hook:
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(defun set-my-settings ()
|
||||||
|
(setq gac-automatically-push-p t))
|
||||||
|
|
||||||
|
(add-hook 'org-mode-hook 'set-my-settings)
|
||||||
|
#+end_src
|
||||||
|
- Set values in a ~.dir-locals.el~ (see [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html#Directory-Variables][Per-Directory Local Variables]]):
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
((nil . ((gac-shell-and . " ; and "))))
|
||||||
|
#+end_src
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
(require 'buttercup)
|
(require 'buttercup)
|
||||||
(require 'git-auto-commit-mode)
|
(require 'git-auto-commit-mode)
|
||||||
|
|
||||||
|
(defun git-auto-commit-mode-tests--get-last-commit-message ()
|
||||||
|
"Get the last commit message from git."
|
||||||
|
(shell-command-to-string "git log --format=format:%s"))
|
||||||
|
|
||||||
(describe "In a git repository"
|
(describe "In a git repository"
|
||||||
:var (temp-dir current-directory)
|
:var (temp-dir current-directory)
|
||||||
|
|
||||||
|
@ -34,7 +38,7 @@
|
||||||
(setq temp-dir (make-temp-file "gac-" t)
|
(setq temp-dir (make-temp-file "gac-" t)
|
||||||
current-directory default-directory
|
current-directory default-directory
|
||||||
default-directory temp-dir)
|
default-directory temp-dir)
|
||||||
(shell-command "git init")
|
(shell-command "git init --initial-branch=gac-test")
|
||||||
(shell-command "git config user.email user@example.com")
|
(shell-command "git config user.email user@example.com")
|
||||||
(shell-command "git config user.name \"User Example\""))
|
(shell-command "git config user.name \"User Example\""))
|
||||||
|
|
||||||
|
@ -55,7 +59,7 @@
|
||||||
(insert "test")
|
(insert "test")
|
||||||
(save-buffer))
|
(save-buffer))
|
||||||
|
|
||||||
(expect (shell-command-to-string "git log --format=format:%s")
|
(expect (git-auto-commit-mode-tests--get-last-commit-message)
|
||||||
:to-match (rx string-start "test" string-end)))))
|
:to-match (rx string-start "test" string-end)))))
|
||||||
|
|
||||||
(describe "When ‘gac-automatically-add-new-files’ is nil"
|
(describe "When ‘gac-automatically-add-new-files’ is nil"
|
||||||
|
@ -68,7 +72,7 @@
|
||||||
(insert "test")
|
(insert "test")
|
||||||
(save-buffer))
|
(save-buffer))
|
||||||
|
|
||||||
(expect (shell-command-to-string "git log --format=format:%s")
|
(expect (git-auto-commit-mode-tests--get-last-commit-message)
|
||||||
:not :to-match (rx string-start "test" string-end))))))
|
:not :to-match (rx string-start "test" string-end))))))
|
||||||
|
|
||||||
(describe "Getting a relative path"
|
(describe "Getting a relative path"
|
||||||
|
@ -140,7 +144,45 @@
|
||||||
(save-buffer))
|
(save-buffer))
|
||||||
|
|
||||||
(expect (gac-relative-file-name temp-file)
|
(expect (gac-relative-file-name temp-file)
|
||||||
:to-equal "[test-test.txt")))))
|
:to-equal "[test-test.txt"))))
|
||||||
|
|
||||||
|
(describe "Getting a commit message"
|
||||||
|
(it "should default to the relative file name"
|
||||||
|
(let* ((temp-file (expand-file-name "test.txt" temp-dir))
|
||||||
|
(buffer (find-file-noselect temp-file)))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(git-auto-commit-mode)
|
||||||
|
(insert "test")
|
||||||
|
(save-buffer))
|
||||||
|
|
||||||
|
(expect (git-auto-commit-mode-tests--get-last-commit-message)
|
||||||
|
:to-equal "test.txt")))
|
||||||
|
|
||||||
|
(it "should use the message specified in ‘gac-default-message’"
|
||||||
|
(let* ((temp-file (expand-file-name "test.txt" temp-dir))
|
||||||
|
(buffer (find-file-noselect temp-file))
|
||||||
|
(gac-default-message "I made a commit!"))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(git-auto-commit-mode)
|
||||||
|
(insert "test")
|
||||||
|
(save-buffer))
|
||||||
|
|
||||||
|
(expect (git-auto-commit-mode-tests--get-last-commit-message)
|
||||||
|
:to-equal "I made a commit!")))
|
||||||
|
|
||||||
|
(it "should use the function result if ‘gac-default-message’ is a function"
|
||||||
|
(let* ((temp-file (expand-file-name "test.txt" temp-dir))
|
||||||
|
(buffer (find-file-noselect temp-file))
|
||||||
|
(gac-default-message
|
||||||
|
(lambda (f)
|
||||||
|
(concat "wip " (gac-relative-file-name f)))))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(git-auto-commit-mode)
|
||||||
|
(insert "test")
|
||||||
|
(save-buffer))
|
||||||
|
|
||||||
|
(expect (git-auto-commit-mode-tests--get-last-commit-message)
|
||||||
|
:to-equal "wip test.txt")))))
|
||||||
|
|
||||||
(provide 'git-auto-commit-mode-tests)
|
(provide 'git-auto-commit-mode-tests)
|
||||||
;;; git-auto-commit-mode-tests.el ends here
|
;;; git-auto-commit-mode-tests.el ends here
|
||||||
|
|
Loading…
Add table
Reference in a new issue