google / yamlfmt

An extensible command line tool or library to format yaml files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do not touch file if there are no changes

terlar opened this issue · comments

It would be nice if the formatter didn't touch the file/updated the timestamp when there was nothing to format:

$ sha256sum test.yaml
dba15ffa54ab8ab6415f322c7f3ee0000518ee2a41028ba40f066895e9b1726e  test.yaml
$ ls -lah test.yaml
-rw-r--r-- 1 terje terje 292 mar  8 13:11 test.yaml
$ yamlfmt test.yaml
$ sha256sum test.yaml
dba15ffa54ab8ab6415f322c7f3ee0000518ee2a41028ba40f066895e9b1726e  test.yaml
$ ls -lah test.yaml
-rw-r--r-- 1 terje terje 292 mar  8 13:12 test.yaml

If this was the case it would work better with treefmt and probably other things as well:
https://numtide.github.io/treefmt/formatters-spec/#2-write-to-changed-files

Thanks for pointing this out @terlar I never thought of that. Opened a PR to fix.

@braydonk Thank you very much, a quick question, how frequently are the releases? I expect that you want to bundle a few more things before making a release?

Yeah, releases aren't on a set cadence. I usually try to finish 2 or 3 things then cut a release. I am finishing up one more thing before cutting the next one, was going to get it on the weekend but ran out of time. Will try to finish it and cut a release in the next few days.

Sorry for the delay, I got sick and couldn't work on this project for a while. v0.12.0 is released and has this fix.

No worries, it is important we take care of ourselves. Hope you feel better now and I wish you great health. Also thank you for notifying me about the release containing the fix.