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

File modification time updates even if autoimport does not change file #179

Closed
Jasha10 opened this issue Jan 20, 2022 · 4 comments
Closed

Comments

@Jasha10
Copy link
Contributor

Jasha10 commented Jan 20, 2022

Feature Request

If I run autoimport on a file and the file is not changed, the modification time of the file should not be changed either.

For example:

$ echo "print(123)" > foo.py
$ cat foo.py
print(123)
$ date -r foo.py
Thu Jan 20 17:37:42 CST 2022
$ autoimport foo.py
$ cat foo.py
print(123)
$ # ^ foo.py was not changed
$ date -r foo.py
Thu Jan 20 17:37:51 CST 2022
$ # ^ file modification time has changed!

autoimport did not modify foo.py, but the modification time was changed.

Possible Solution

Perhaps autoimport could check whether the file would be modified, and only touch the file if a nonzero diff would occur.

Additional context

I use makefiles and other similar tools which keep track of file modification time. If autoimport does not change the file's contents, modification of the file modification time triggers a false-positive make/build cycle.

@lyz-code
Copy link
Owner

Hi @Jasha10 thanks again for opening the issue, I'll look into it next week, as always, if you can make a PR I'll be grateful

@lyz-code
Copy link
Owner

I'd add it around line 30 of src/autoimport/services.py, the test might be tricky to
make though

@lyz-code
Copy link
Owner

Fixed in #181 and released under 1.0.2, plz test if it works for you

@Jasha10
Copy link
Contributor Author

Jasha10 commented Jan 22, 2022

Yes, it's working. Thanks!

@Jasha10 Jasha10 closed this as completed Jan 22, 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