macisamuele / language-formatters-pre-commit-hooks

Collection of custom pre-commit hooks.
Apache License 2.0
116 stars 58 forks source link

Multiple yaml in one file fails to format #120

Closed spasalkar-uptycs closed 1 year ago

spasalkar-uptycs commented 1 year ago

Multiple yaml content in one file, it fails to validate

---
apiVersion: test
kind: test
---
apiVersion: test2
kind: test2
---
macisamuele commented 1 year ago

@spasalkar-uptycs thanks for the report. Could you please post details around the used version of the library and the full report of the error?

macisamuele commented 1 year ago

Tried to verify it myself and I did not manage to reproduce. @spasalkar-uptycs if the problem still persists, please open a new issue and provide info about the installed libraries on your virtual environment (specifically language-formatters-pre-commit-hooks and ruamel.yaml).

(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ git rev-parse HEAD                                                     [10:27:32]

aea4afc8a43ef9bb825575b6e590815744bb3ab0
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ git status                                                             [10:27:33]
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
    a.yaml

nothing added to commit but untracked files present (use "git add" to track)
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ cat a.yaml                                                             [10:27:36]
---
apiVersion: test
kind: test
---
apiVersion: test2
kind: test2
---
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ pretty-format-yaml a.yaml                                              [10:27:37]
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ echo $?                                                                [10:27:41]
0
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ cat a.yaml                                                             [10:27:43]
---
apiVersion: test
kind: test
---
apiVersion: test2
kind: test2
---
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ pretty-format-yaml a.yaml                                              [10:27:44]
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ pip freeze | grep language-formatters-pre-commit-hooks                 [10:29:47]
language-formatters-pre-commit-hooks @ file:///Users/maci/github/language-formatters-pre-commit-hooks/.tox/.tmp/package/26/language_formatters_pre_commit_hooks-2.6.0.tar.gz
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $ pip freeze | grep ruamel.yaml                                          [10:29:49]
ruamel.yaml==0.17.21
(py311) maci:language-formatters-pre-commit-hooks/ (master✗) $                                                                        [10:29:58]
spasalkar-uptycs commented 1 year ago

@macisamuele It's fixed. Thanks