Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## master (unreleased)

### Changes
* [#1958](https://github.com/bbatsov/projectile/issues/1958): Exclude `.projectile-cache.eld` from search results (ripgrep/ag/grep) by default.
* [#1954](https://github.com/bbatsov/projectile/issues/1954): update ELisp for usage.html / "Removal of missing projects"
* [#1947](https://github.com/bbatsov/projectile/issues/1947): `projectile-project-name` should be marked as safe
* Set `projectile-auto-discover` to `nil` by default.
Expand Down
3 changes: 2 additions & 1 deletion projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,11 @@ Similar to '#' in .gitignore files."
:package-version '(projectile . "2.2.0"))

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

Expand Down
26 changes: 26 additions & 0 deletions test/projectile-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,32 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(expect (projectile-ignored-file-p "/path/to/project/TAGS") :to-be-truthy)
(expect (projectile-ignored-file-p "/path/to/project/foo.el") :not :to-be-truthy)))

(describe "projectile-globally-ignored-files"
(it "includes TAGS file by default"
(expect (member projectile-tags-file-name projectile-globally-ignored-files) :to-be-truthy))
(it "includes cache file by default"
(expect (member projectile-cache-file projectile-globally-ignored-files) :to-be-truthy))
(it "causes cache file to be ignored via projectile-ignored-file-p"
(spy-on 'projectile-ignored-files :and-return-value
(list (concat "/path/to/project/" projectile-cache-file)
(concat "/path/to/project/" projectile-tags-file-name)))
(expect (projectile-ignored-file-p (concat "/path/to/project/" projectile-cache-file)) :to-be-truthy)
(expect (projectile-ignored-file-p "/path/to/project/source.el") :not :to-be-truthy)))

(describe "projectile-globally-ignored-files :safe predicate"
(it "accepts list of strings as safe"
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
(expect (funcall pred '("file1" "file2")) :to-be-truthy)))
(it "rejects list containing non-strings as unsafe"
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
(expect (funcall pred '("file1" 123)) :not :to-be-truthy)))
(it "accepts empty list as safe"
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
(expect (funcall pred '()) :to-be-truthy)))
(it "rejects non-list as unsafe"
(let ((pred (get 'projectile-globally-ignored-files 'safe-local-variable)))
(expect (funcall pred "not-a-list") :not :to-be-truthy))))

(describe "projectile-ignored-files"
(it "returns list of ignored files"
(spy-on 'projectile-project-root :and-return-value "/path/to/project")
Expand Down