Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape periods in "projectile-globally-ignored-directories" #1762

Merged
merged 2 commits into from
Mar 29, 2022

Conversation

maxtrussell
Copy link
Contributor

@maxtrussell maxtrussell commented Mar 13, 2022

The unescaped periods were causing unexpected directories to be ignored.

E.g. for the following go project, the configitem directory was ignored because it matched the regex ".git":

$ find pkg -type f
pkg/metrics/argus.go
pkg/secrets/secrets.go
pkg/dynamo/dynamo.go
pkg/utils/types.go
pkg/utils/utils.go
pkg/utils/errors.go
pkg/configitem/configitem.go
pkg/api/handlers.go
pkg/api/middleware.go

Replace this placeholder text with a summary of the changes in your PR.
The more detailed you are, the better.


Before submitting a PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)

Thanks!

The unescaped periods were causing unexpected directories to be ignored.

E.g. for the following go project, the configitem directory was ignored because it matched the regex ".git":
$ find pkg -type f
pkg/metrics/argus.go
pkg/secrets/secrets.go
pkg/dynamo/dynamo.go
pkg/utils/types.go
pkg/utils/utils.go
pkg/utils/errors.go
pkg/configitem/configitem.go
pkg/api/handlers.go
pkg/api/middleware.go
@bbatsov
Copy link
Owner

bbatsov commented Mar 21, 2022

Can you elaborate on this a bit? I was under the impression the items on this list were used for literal matches, but if they are used as regular expressions we can make them more specific.

@maxtrussell
Copy link
Contributor Author

maxtrussell commented Mar 21, 2022

Can you elaborate on this a bit? I was under the impression the items on this list were used for literal matches, but if they are used as regular expressions we can make them more specific.

@bbatsov Happy to! The items on the list end up getting passed to projectile-ignored-directory-p here: https://github.com/bbatsov/projectile/blob/master/projectile.el#L1308-L1313

Which in turn passes the list to a string-match-p here: https://github.com/bbatsov/projectile/blob/master/projectile.el#L1726-L1729

Now confusingly string-match-p seems to match using regular expressions. You can find the docs for it on this page: https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Search.html

ELISP> (string-match-p ".git" "configitem")
4 (#o4, #x4, ?\C-d)
ELISP> (string-match-p "\\.git" "configitem")
nil
ELISP> (string-match-p "\\.git" ".git")
0 (#o0, #x0, ?\C-@)

Note any non-nil output from string-match-p indicates a match. The return value is just the index of the match within the string.

Also the comments on projectile-globally-ignored-directories directly mention that regular expressions are used: https://github.com/bbatsov/projectile/blob/master/projectile.el#L417

It's probably worth adding start and end anchors to projectile-globally-ignored-directories so that wacky directory names like "foo.git.bar" won't be ignored

@bbatsov
Copy link
Owner

bbatsov commented Mar 25, 2022

It's probably worth adding start and end anchors to projectile-globally-ignored-directories so that wacky directory names like "foo.git.bar" won't be ignored

Agreed.

@maxtrussell
Copy link
Contributor Author

It's probably worth adding start and end anchors to projectile-globally-ignored-directories so that wacky directory names like "foo.git.bar" won't be ignored

Agreed.

Done

@bbatsov bbatsov merged commit f3468e8 into bbatsov:master Mar 29, 2022
@bbatsov
Copy link
Owner

bbatsov commented Mar 29, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants