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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with overwriting files since 1.0.6 caused by problem with gitignore parsing #18

Closed
kirberich opened this issue Apr 22, 2022 · 6 comments

Comments

@kirberich
Copy link

Hi!

I just noticed today that formatting any django html file with the djlint extension results in the file getting overwritten with "No files to check! 馃槩", on version 1.0.7.

If I roll back to 1.0.6 this still happens, but on 1.0.5 it doesn't.

I've reinstalled vscode and removed global settings, as well as resetting any workspace-specific settings.

After a bit of investigating, I found that it's caused, somehow, by the project's gitignore file - it was ignoring folders named var/, and that causes the extension to not find any files anymore. To be clear, it's unrelated to the filename - any file in any folder within the project causes the error.

Note that this doesn't seem to be caused by djlint itself - if i manually run djlint --use-gitignore <file> it works correctly, even with the var/ in the gitignore, only ignoring the file and producing the message if the path to the file is actually included in the gitignore.

To reproduce

  • Create a new workspace
  • Add a pyproject.toml with [tool.djlint] and use_gitignore = true
  • Add a .gitignore with just var/
  • Try to format any file, contents get replaced with the no files to check message
@monosans
Copy link
Member

Hi.

I have not been able to reproduce this problem.

I see 2 ways out of this situation:

  1. Make a check in the code for the absence of No files to check! 馃槩.
  2. Write in README that this option is not supported and leads to unpredictable results, as is currently done with linter_output_format.

If you have any ideas about this, I'd be happy to hear it.

@kirberich
Copy link
Author

Alright I dug a bit deeper and figured it out, it is actually a djlint bug, and not a bug in the extension.

It's caused by using the stdin as input combined with the gitignore. On my (mac) machine, djlint puts the temp file here:

djlint temp file: /var/folders/hc/4yqwct_n58v1jstvzm2t2hpr0000gp/T/tmpud1gl7gd

It then wrongly checks the path of its own temp file against the gitignore, which in my case matches because of the var/ line.

This didn't happen before 91699a6 because it was then using the filename instead of stdin - going back to that might be a fast way to fix it, but I'll also report this to djlint

@monosans
Copy link
Member

This didn't happen before 91699a6 because it was then using the filename instead of stdin

Using stdin was necessary to fix #13.

@kirberich
Copy link
Author

Makes sense! I think if djlint agree with me that when using stdin the gitignore should always be set to false (why give it the content of a file that should be ignored), then this problem will go away on its own

I reported it here: djlint/djLint#224

@monosans
Copy link
Member

With the djLint 1.0.0 update, is everything working as it should now?

@monosans
Copy link
Member

monosans commented May 1, 2022

Closing the issue now. If the issue remains, let me know and I will reopen it.

@monosans monosans closed this as completed May 1, 2022
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

No branches or pull requests

2 participants