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

Invalidate cache when prjfmt.toml is modified #16

Closed
basile-henry opened this issue Jan 26, 2021 · 1 comment
Closed

Invalidate cache when prjfmt.toml is modified #16

basile-henry opened this issue Jan 26, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@basile-henry
Copy link
Contributor

At the moment, when the state of the repo is cached, modifications to the prjfmt.toml file are not used until the repo is modified because prjfmt assumes everything is already formatted.

I assume that if a formatter is updated/version changed, then a similar issue where prjfmt will assume it doesn't need to run arises.

This logic of cache invalidation can probably become complicated, maybe we could just add a command to the CLI to let the user invalidate the cache manually: prjfmt --clear-cache?

@zimbatm zimbatm added the enhancement New feature or request label Jan 27, 2021
@zimbatm
Copy link
Member

zimbatm commented Jan 27, 2021

I think this can be fixed with the following changes:

  • expand the path of the formatter binary to get an absolute value. Record that into the manifest.
  • record the mtime of the formatted binary
  • when checking if a file has "changed", also compare the command that has been used.

That should capture 99% of the cases.

There is still the issue that the formatters themselves might have a config file that gets changed so adding the --clear-cache option will be necessary.
The cache should compare (cmd, mtime) instead of just the time. That way if the command changes or a new version of the software is installed, it will re-run the formatter.

brianmcgee added a commit that referenced this issue May 13, 2024
Closes #8

Signed-off-by: Brian McGee <brian@bmcgee.ie>

Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/16
Reviewed-by: Jonas Chevalier <zimbatm@noreply.git.numtide.com>
Co-authored-by: Brian McGee <brian@bmcgee.ie>
Co-committed-by: Brian McGee <brian@bmcgee.ie>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants