Add option to prevent new files from being added to git
Setting ‘gac-automatically-add-new-files-p’ to t will tell git-auto-commit-mode not to try adding new files to the git repository.
This commit is contained in:
parent
b0db5b841b
commit
d8d9dab5d2
4 changed files with 49 additions and 16 deletions
2
NEWS
2
NEWS
|
@ -6,6 +6,8 @@
|
|||
- Only try to commit when changes have been discovered in the file. By
|
||||
extension git-auto-commit-mode won't ask for a summary to a commit that it
|
||||
won't make.
|
||||
- Add option to prevent new (untracked) files from being added to the git
|
||||
repository automatically, =gac-automatically-add-new-files-p=.
|
||||
|
||||
* v4.5.0
|
||||
|
||||
|
|
|
@ -76,6 +76,10 @@
|
|||
repository's ~HEAD~ to its default upstream. Setting up the
|
||||
upstream is the user's responsibility.
|
||||
|
||||
- =gac-automatically-add-new-files-p= ::
|
||||
A boolean value indicating whether or not git-auto-commit-mode should add
|
||||
new (untracked) files to the repository.
|
||||
|
||||
- =gac-ask-for-summary-p= :: A boolean value indicating whether or not
|
||||
git-auto-commit-mode should ask the user for a commit message every time
|
||||
a commit is made. *Note*: Since the summary is asked for before the commit,
|
||||
|
|
|
@ -50,6 +50,12 @@ If non-nil a git push will be executed after each commit."
|
|||
:risky t)
|
||||
(make-variable-buffer-local 'gac-automatically-push-p)
|
||||
|
||||
(defcustom gac-automatically-add-new-files-p t
|
||||
"Should new (untracked) files automatically be committed to the repo?"
|
||||
:tag "Automatically add new files"
|
||||
:group 'git-auto-commit-mode
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom gac-ask-for-summary-p nil
|
||||
"Ask the user for a short summary each time a file is committed?"
|
||||
:tag "Ask for a summary on each commit"
|
||||
|
@ -185,7 +191,8 @@ should already have been set up."
|
|||
(defun gac--after-save (buffer)
|
||||
(unwind-protect
|
||||
(when (and (buffer-live-p buffer)
|
||||
(or (not (gac--buffer-is-tracked buffer))
|
||||
(or (and gac-automatically-add-new-files-p
|
||||
(not (gac--buffer-is-tracked buffer)))
|
||||
(gac--buffer-has-changes buffer)))
|
||||
(gac-commit buffer)
|
||||
(with-current-buffer buffer
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
(require 'git-auto-commit-mode)
|
||||
|
||||
(describe "New files"
|
||||
(describe "When ‘gac-automatically-add-new-files’ is t"
|
||||
(it "Should be added to git"
|
||||
(let* ((temp-dir (make-temp-file "gac-" t))
|
||||
(let* ((gac-automatically-add-new-files-p t)
|
||||
(temp-dir (make-temp-file "gac-" t))
|
||||
(temp-file (expand-file-name "test" temp-dir))
|
||||
(default-directory temp-dir))
|
||||
(unwind-protect
|
||||
|
@ -44,5 +46,23 @@
|
|||
:to-match (rx string-start "test" string-end)))
|
||||
(delete-directory temp-dir t)))))
|
||||
|
||||
(describe "When ‘gac-automatically-add-new-files’ is nil"
|
||||
(it "Shouldn’t be added to git"
|
||||
(let* ((gac-automatically-add-new-files-p nil)
|
||||
(temp-dir (make-temp-file "gac-" t))
|
||||
(temp-file (expand-file-name "test" temp-dir))
|
||||
(default-directory temp-dir))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(shell-command "git init")
|
||||
(let ((buffer (find-file-noselect temp-file)))
|
||||
(with-current-buffer buffer
|
||||
(git-auto-commit-mode)
|
||||
(insert "test")
|
||||
(save-buffer)))
|
||||
(expect (shell-command-to-string "git log --format=format:%s")
|
||||
:not :to-match (rx string-start "test" string-end)))
|
||||
(delete-directory temp-dir t))))))
|
||||
|
||||
(provide 'git-auto-commit-mode-tests)
|
||||
;;; git-auto-commit-mode-tests.el ends here
|
||||
|
|
Loading…
Reference in a new issue