Skip to content

Comments

Update pre-commit hook google/yamlfmt to v0.21.0#17

Open
renovate[bot] wants to merge 1 commit intomainfrom
renovate/google-yamlfmt-0.x
Open

Update pre-commit hook google/yamlfmt to v0.21.0#17
renovate[bot] wants to merge 1 commit intomainfrom
renovate/google-yamlfmt-0.x

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Jun 19, 2025

This PR contains the following updates:

Package Type Update Change
google/yamlfmt repository minor v0.17.0v0.21.0

Note: The pre-commit manager in Renovate is not supported by the pre-commit maintainers or community. Please do not report any problems there, instead create a Discussion in the Renovate repository if you have any questions.


Release Notes

google/yamlfmt (google/yamlfmt)

v0.21.0

Compare Source

Sorry to folks who were likely waiting on the stuff in this release, it's pretty packed. I got sick in December and took my holiday leave early, and I decided to fully and completely disconnect. Lots of stuff packed into this one now that I'm back. Happy new year!

Features

Force single or double quotes #​288

You can now force all quoted strings in a yaml document to be ' or ". See the basic formatter docs for more info.

KYAML Formatter #​302

yamlfmt can now support the new KYAML format from the Kubernetes project. The support for this is via a new formatter type called kyaml. I built support for alternate formatters into the architecture of yamlfmt all the way back when I first started the tool, but this is the first time I'm actually publishing a new formatter. I recommend a full read of the formatter documentation to get a sense of how to use this alternate formatter.

Bug Fixes

Gitlab output format #​272

I don't use Gitlab and didn't implement the feature so I'm not sure if this has been broken the whole time or if there was a schema change somewhere that bricked it, but Gitlab output format from yamlfmt was missing some required fields. This should work now with the new fields added into the output schema.

/dev/stdin as an argument instead of - did not work #​291

You're only allowed to read from stdin once in POSIX, but I inadvertently had a codepath that would read the file for a different purpose before reading it for formatting. This caused yamlfmt not to work under that circumstance. This edge case is handled now.

Filepath collector panic #​300

In a scenario where filepath.Walk fails to read something from the filesystem, I wasn't handling the error case properly. This never came up because I never had an error case ever appear locally and the linter that would yell at me about missed error checks didn't pick up that particular pattern that filepath.Walk propogates errors with. There should no longer be panics in error scenarios; new behaviour is that paths that failed to read will be surfaced and all other successful reads will be formatted.

Contributions

Thanks to @​slipknois for fixing the Gitlab output format.

v0.20.0

Compare Source

Features

-version flag works when using go install

The previous method of version retrieval only worked when downloading the binary through GitHub releases or one of the community-made packages. When using go install, the version would always be dev because the ldflags weren't being used to set the version. It now falls back to debug.BuildInfo so that the version will be displayed properly when installing through this method.

Fixes

Performance Issues when formatting large files

Details in #​283. Two fixes were submitted:

  • Use of strings.Repeat instead of manually looping during string construction #​284
  • Changing logic to only construct a diff string when the debug code is active #​287

If you have experienced similar performance issues, these fixes should help.

Contributors

Thanks @​artur-beznosyuk-verkada for the performance issue analysis and the strings.Repeat fix.

v0.19.0

Compare Source

With v0.19.0, I have fully reverted all the pre-commit changes done in the v0.18.0 line. I apologize for any drama this caused in your CI. I have learned my lesson and won't modify the pre-commit hook any further. Maybe something will change in the future if someone joins the team maintaining the hook (see https://redirect.github.com/google/yamlfmt/discussions/278) but I personally will not do it.

I have updated the pre-commit docs to include some configuration tricks for how to get around the problems this original form of the hook can cause. Hopefully this should be enough to resolve problems that some users originally experienced that inspired my attempt in the v0.18.0 series.

v0.18.1

Compare Source

The previous fix for pre-commit was poorly done. The default experience for a pre-commit hook is to pass all the discovered filenames to the entry, and when yamlfmt receives references to exact files in its list of arguments, by design it will run them through the formatter without checking whether the config would want to run them. With the fix in v0.18.0, this would cause all files in a repo, including non-yaml ones, to run through the formatter unconditionally. I think I have finally settled on a proper implementation, which is explained in the docs.

On a related note, if you are knowledgeable about pre-commit and interested in the future of this project as a pre-commit hook, please take a look at my recent announcement: #​278

v0.18.0

Compare Source

The primary reason for this release is a change to the pre-commit hook that might be breaking to some users.

Features

pre-commit hook no longer specifies filetypes

The expectation for yamlfmt is to be run in a working directory of many different filetypes, and to configure what you as a user want the tool to run on based on configuration (file extensions, doublestar patterns, etc). The hook no longer specifies types: [yaml] like it used to. You can restore this behaviour by overriding it in your pre-commit config like so:

- repo: https://github.com/google/yamlfmt
  rev: v0.18.0
  hooks:
    - id: yamlfmt
      types: [yaml]

However, you will likely have a better experience by reconfiguring yamlfmt to match the intended experience.

Default usage message on misuse of command

If you use the command yamlfmt with no arguments, and no config is discovered, the tool will now output a default usage message to indicate to the user how to properly use the command.

v0.17.2

Compare Source

Bug Fixes

Alias nodes no longer come with an extra whitespace

In an attempt to fix a behaviour in yaml.v3's default encoding behaviour that would produce invalid YAML what an alias was used as a key (see #​242) I introduced a regression where my fix was too wide of a net and produced an additional whitespace in scenarios where it wasn't necessary (see #​250). To the extent of my testing this appears to be fixed now, however if that is not the case please feel free to re-open #​250 with the example case that isn't covered or open a new issue.

Contributors

Thank you @​octo for the bug fix in #​260!

v0.17.1

Compare Source

Made this patch release because I don't have any upcoming work planned on yamlfmt at the moment and wanted to get this bugfix released.

Bug Fixes

yaml files with just comments had their contents erased.

If a yaml file had just comments, previously yamlfmt would erase the contents. This was an oversight on how yaml.v3 parses a file like this. Comment parsing works such that any comments found are attached as head, line, or foot comments to a given node. Since a yaml file with just comments has no nodes, the comment wouldn't be anywhere in the parse tree because the parse tree would be empty. Empty parse tree = yamlfmt produces an empty document. This is now properly treated as an edge case and will retain the contents as originally passed in if the file is just comments.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot changed the title Update pre-commit hook google/yamlfmt to v0.17.1 Update pre-commit hook google/yamlfmt to v0.17.2 Jun 24, 2025
@renovate renovate bot force-pushed the renovate/google-yamlfmt-0.x branch from 0acd56b to a6d1a63 Compare June 24, 2025 05:34
@renovate renovate bot changed the title Update pre-commit hook google/yamlfmt to v0.17.2 Update pre-commit hook google/yamlfmt to v0.18.0 Oct 14, 2025
@renovate renovate bot force-pushed the renovate/google-yamlfmt-0.x branch from a6d1a63 to 2e4a428 Compare October 14, 2025 18:37
@renovate renovate bot changed the title Update pre-commit hook google/yamlfmt to v0.18.0 Update pre-commit hook google/yamlfmt to v0.18.1 Oct 16, 2025
@renovate renovate bot force-pushed the renovate/google-yamlfmt-0.x branch from 2e4a428 to 4e62453 Compare October 16, 2025 22:25
@renovate renovate bot changed the title Update pre-commit hook google/yamlfmt to v0.18.1 Update pre-commit hook google/yamlfmt to v0.19.0 Oct 17, 2025
@renovate renovate bot force-pushed the renovate/google-yamlfmt-0.x branch from 4e62453 to 2f2b36e Compare October 17, 2025 15:01
@renovate renovate bot changed the title Update pre-commit hook google/yamlfmt to v0.19.0 Update pre-commit hook google/yamlfmt to v0.20.0 Oct 22, 2025
@renovate renovate bot force-pushed the renovate/google-yamlfmt-0.x branch from 2f2b36e to 1cf9394 Compare October 22, 2025 19:28
@renovate renovate bot changed the title Update pre-commit hook google/yamlfmt to v0.20.0 Update pre-commit hook google/yamlfmt to v0.21.0 Jan 5, 2026
@renovate renovate bot force-pushed the renovate/google-yamlfmt-0.x branch from 1cf9394 to 95b3f11 Compare January 5, 2026 21:31
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

Successfully merging this pull request may close these issues.

0 participants