-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat: gitignore support #832
Conversation
FYI @bradzacher, if you have the time, it would be interesting to know how this impacts Canva's codebase and if there's anything that should change in this PR to make things easier. I'm sure there's probably some edge case that this doesn't take into account. |
What's the best way to grab a binary for this PR? Checkout and build? |
@bradzacher oh, sorry! Yeah, checkout and build. git clone https://github.com/dprint/dprint
gh pr checkout 832
cargo build # creates ./target/debug/dprint |
I'll probably merge this one over the weekend then we can address any issues in followups. |
Yeah I gotta figure out how to test this out cos we currently have everything wired into nix as a binary deployment setup. So replacing the dprint binary without a github release url will take a sec. |
Testing the two binaries:
It looks like there are some incorrectly included files due to this behaviour. {
"includes": [
"*.json",
"!some/path/to/**/*.json",
],
} And then # some/path/to/a/file/.gitignore
!content.json Currently Another example would be that we have: {
"excludes": [
"**/.vscode/*",
"!**/.vscode/extensions.json",
"!**/.vscode/OWNERS",
"!**/.vscode/README.md",
"!**/.vscode/*.css-data.json"
],
} And we have # root .gitignore
# ignore VS Code personal settings
**/.vscode/*
# except extensions recommendations
!**/.vscode/extensions.json
!**/.vscode/OWNERS
!**/.vscode/README.md
!**/.vscode/*.css-data.json And with this change those files are now included to be formatted. |
Thanks! Will investigate soon. |
One final example. # root .gitignore
**/target
# some/folder/.gitignore
# don't exclude this target folder
!/target And then {
"excludes": [
"!web/src/ui/publish/menu/publish_app/target",
]
} Those files under |
So (as you may guess) we have config generation logic at play here.
We also have logic based on
And we generate The logic itself is pretty simple - it's just that it does generate a pretty cooked config file which has includes, excludes, not includes and not excludes. |
Hmmm... tried this one out and it seemed to work. Maybe I'm doing something wrong in this test case: daf4c8a#diff-38287cc5b9dd24e7cd7e8e42fec4f0ece050cef16b7bcc5344138143f4e95413R493 Maybe the real world example is slightly different?
For this one, I'm going to go with the new behaviour because it makes unignoring gitignored files possible. Previously dprint would treat negative globs the same as positive globs in "excludes" (so it would just take the |
Going to merge this one for the time being. We can follow up with fixes after. |
😬 I feel compelled to say sorry at this juncture XD |
Cycling back here. A few weeks ago I was able to update our config setup to remove a whole bunch of lines. TL;DR - our Java team decided to stop using google-java-formatter (via dprint) and go back to intellij-format. So that meant there was a bunch of folder opt-ins and opt-outs that I could remove. That change cut ~200 lines of Last week I updated Canva to dprint 0.47.1. Today I updated our So big win all round on the config front! I'm guessing all of this config simplification will also help us with issues like this one: #877 |
Takes the .gitignore into account when figuring out what to format. Files that are excluded via the .gitignore can be unexcluded via a negated exclude pattern.
Breaking:
Closes #378
Closes #833