-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Set glob's :hidden
when pattern
starts with dot
#114
Conversation
src/babashka/fs.cljc
Outdated
(str/includes? pattern "/"))))] | ||
(match root (str "glob:" pattern) (assoc opts :recursive recursive))))) | ||
(str/includes? pattern "/")))) | ||
hidden (:hidden opts (when-not win? (str/starts-with? pattern ".")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say let's also do this for Windows, unless the hidden option is explicitly set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense I think.
I didn't do it as what I understood from glob's docstring is that being 'dotted' and 'hidden' are orthogonal things on Windows.
So .git*
already finds .gitignore
and it can't be concluded from a dot-pattern that hidden files should be considered - but in the end we only add dotfiles that are hidden to the haystack.
Will amend it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, re-ran API generation and added some formatting to docstrings.
So this would e.g. find ~/.gitconfig: `(fs/glob (home) ".git*")`
825f292
to
8115e54
Compare
@@ -100,7 +100,12 @@ | |||
sym-link (fs/create-sym-link (fs/file tmp-dir2 "sym-link") tmp-dir1)] | |||
(is (empty? (fs/glob sym-link "**"))) | |||
(is (= 1 (count (fs/glob sym-link "**" {:follow-links true})))) | |||
(is (= 1 (count (fs/glob (fs/real-path sym-link) "**"))))))) | |||
(is (= 1 (count (fs/glob (fs/real-path sym-link) "**")))))) | |||
(testing ":hidden option" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept this test non-Windows as the extra hassle to set a hidden attribute seems not worth it.
Merged with minor changes on master |
So this would e.g. find ~/.gitconfig:
(fs/glob (home) ".git*")
Issue: #113
Please answer the following questions and leave the below in as part of your PR.
This PR corresponds to an issue with a clear problem statement.
This PR contains a test to prevent against future regressions
I have updated the CHANGELOG.md file with a description of the addressed issue.