Skip to content

Commit 072cc14

Browse files
committed
fix: mark projectile-globally-ignored-files as safe local variable
- Add :safe predicate to projectile-globally-ignored-files custom variable - Update tests to verify safe local variable predicate behavior - Document change in CHANGELOG.md
1 parent 9325c45 commit 072cc14

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## master (unreleased)
44

55
### Changes
6+
* [#1958](https://github.com/bbatsov/projectile/issues/1958): Exclude `.projectile-cache.eld` from search results (ripgrep/ag/grep) by default.
67
* [#1954](https://github.com/bbatsov/projectile/issues/1954): update ELisp for usage.html / "Removal of missing projects"
78
* [#1947](https://github.com/bbatsov/projectile/issues/1947): `projectile-project-name` should be marked as safe
89
* Set `projectile-auto-discover` to `nil` by default.

projectile.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,11 @@ Similar to '#' in .gitignore files."
402402
:package-version '(projectile . "2.2.0"))
403403

404404
(defcustom projectile-globally-ignored-files
405-
(list projectile-tags-file-name)
405+
(list projectile-tags-file-name projectile-cache-file)
406406
"A list of files globally ignored by projectile.
407407
Note that files aren't filtered if `projectile-indexing-method'
408408
is set to `alien'."
409+
:safe (lambda (x) (not (remq t (mapcar #'stringp x))))
409410
:group 'projectile
410411
:type '(repeat string))
411412

test/projectile-test.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,32 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
352352
(expect (projectile-ignored-file-p "/path/to/project/TAGS") :to-be-truthy)
353353
(expect (projectile-ignored-file-p "/path/to/project/foo.el") :not :to-be-truthy)))
354354

355+
(describe "projectile-globally-ignored-files"
356+
(it "includes TAGS file by default"
357+
(expect (member projectile-tags-file-name projectile-globally-ignored-files) :to-be-truthy))
358+
(it "includes cache file by default"
359+
(expect (member projectile-cache-file projectile-globally-ignored-files) :to-be-truthy))
360+
(it "causes cache file to be ignored via projectile-ignored-file-p"
361+
(spy-on 'projectile-ignored-files :and-return-value
362+
(list (concat "/path/to/project/" projectile-cache-file)
363+
(concat "/path/to/project/" projectile-tags-file-name)))
364+
(expect (projectile-ignored-file-p (concat "/path/to/project/" projectile-cache-file)) :to-be-truthy)
365+
(expect (projectile-ignored-file-p "/path/to/project/source.el") :not :to-be-truthy)))
366+
367+
(describe "projectile-globally-ignored-files :safe predicate"
368+
(it "accepts list of strings as safe"
369+
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
370+
(expect (funcall pred '("file1" "file2")) :to-be-truthy)))
371+
(it "rejects list containing non-strings as unsafe"
372+
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
373+
(expect (funcall pred '("file1" 123)) :not :to-be-truthy)))
374+
(it "accepts empty list as safe"
375+
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
376+
(expect (funcall pred '()) :to-be-truthy)))
377+
(it "rejects non-list as unsafe"
378+
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
379+
(expect (funcall pred "not-a-list") :not :to-be-truthy))))
380+
355381
(describe "projectile-ignored-files"
356382
(it "returns list of ignored files"
357383
(spy-on 'projectile-project-root :and-return-value "/path/to/project")

0 commit comments

Comments
 (0)