Open ggoretkin-bdai opened 1 year ago
Hi @ggoretkin-bdai thanks for taking the time to open an issue. Maybe I'm understanding you wrong but the snippet you provided is not a valid yaml way to break long lines. You need to use the >
or |
operators. For example the next snippet is untouched by yamlfix
:
---
jobs:
run_jobs:
steps:
- name: Upload coverage to Codecov
with:
files: >
./projects/aaaaaaaaaaaaaaaaa/ws/build/formation_planner/coverage.xml,
./projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./projects/bbbb_examples/ws/build/bbbb_examples/coverage.xml,
./projects/ccccccccccccccccccc/ws/build/diagnose_repair/coverage.xml,
projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./ws/build/abcd_abc/coverage.xml, ./ws/build/bbbb_bbbbter/coverage.xml,
./ws/build/abcd_abc_wrappers/coverage.xml
In case you're not familiar with these operators here is a little cheatsheet
Use >
most of the time: interior line breaks are stripped out, although you
get one at the end:
key: >
Your long
string here.
Use |
if you want those line breaks to be preserved as \n
(for instance,
embedded markdown with paragraphs):
key: |
### Heading
* Bullet
* Points
Use >-
or |-
instead if you don't want a line break appended at the end.
Thanks for the quick reply, and the explanation. I believe there is still something going on that I could use help understanding. The exact situation I am running into is:
jobs:
run_jobs:
steps:
- name: Upload coverage to Codecov
with:
files: ./projects/aaaaaaaaaaaaaaaaa/ws/build/formation_planner/coverage.xml, ./projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml, ./projects/bbbb_examples/ws/build/bbbb_examples/coverage.xml, ./projects/ccccccccccccccccccc/ws/build/diagnose_repair/coverage.xml, projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml, ./ws/build/abcd_abc/coverage.xml, ./ws/build/bbbb_bbbbter/coverage.xml, ./ws/build/abcd_abc_wrappers/coverage.xml
Note that it is a single long line at the end. yamlfix
turns it into
---
jobs:
run_jobs:
steps:
- name: Upload coverage to Codecov
with:
files: ./projects/aaaaaaaaaaaaaaaaa/ws/build/formation_planner/coverage.xml,
./projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./projects/bbbb_examples/ws/build/bbbb_examples/coverage.xml, ./projects/ccccccccccccccccccc/ws/build/diagnose_repair/coverage.xml,
projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./ws/build/abcd_abc/coverage.xml, ./ws/build/bbbb_bbbbter/coverage.xml,
./ws/build/abcd_abc_wrappers/coverage.xml
From that I inferred some things about YAML that were not true (thank you for pointing out the >
).
Furthermore, when I give this to yamlfix
---
jobs:
run_jobs:
steps:
- name: Upload coverage to Codecov
with:
files: >
./projects/aaaaaaaaaaaaaaaaa/ws/build/formation_planner/coverage.xml,
./projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./projects/bbbb_examples/ws/build/bbbb_examples/coverage.xml, ./projects/ccccccccccccccccccc/ws/build/diagnose_repair/coverage.xml,
projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./ws/build/abcd_abc/coverage.xml, ./ws/build/bbbb_bbbbter/coverage.xml,
./ws/build/abcd_abc_wrappers/coverage.xml
it becomes
---
jobs:
run_jobs:
steps:
- name: Upload coverage to Codecov
with:
files: >-
./projects/aaaaaaaaaaaaaaaaa/ws/build/formation_planner/coverage.xml,
./projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./projects/bbbb_examples/ws/build/bbbb_examples/coverage.xml, ./projects/ccccccccccccccccccc/ws/build/diagnose_repair/coverage.xml,
projects/aaaaaaaaaaaaaaaaa/ws/build/aaaaaaaaaaaaaaaaa_abc/coverage.xml,
./ws/build/abcd_abc/coverage.xml, ./ws/build/bbbb_bbbbter/coverage.xml,
./ws/build/abcd_abc_wrappers/coverage.xml
>
becomes >-
. I also expected that the default line length of 80 chars would force each path on its own line.
The >
to >-
is not a big deal because it's always best not to have the \n
at the end of the string.
I can reproduce the long line not being handled. It seems that the string ./projects/bbbb_examples/ws/build/bbbb_examples/coverage.xml,
is smaller than 80 characters and therefore it doesn't know how to split it. The issue can be either in the patch_sequence_style
function or upstream from ruyaml
which we use to handle the long string splitting
Apparently it's a bug in the ruyaml
side, but it looks like it's dead
@lyz-code How can I avoid formatting list items? For example:
build:
stage: build
before_script:
- *docker_login
script:
- DOCKER_BUILDKIT=1 docker build .
--cache-from $CI_REGISTRY_IMAGE:latest
--platform=linux/amd64
--network=host
--progress=plain
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
Transformed into:
build:
stage: build
before_script:
- *docker_login
script:
- DOCKER_BUILDKIT=1 docker build . --cache-from $CI_REGISTRY_IMAGE:latest --platform=linux/amd64 --network=host --progress=plain
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
Thank you!
Description and Current Behavior
yamlfix
turnsinto
Desired behavior
breakable lines should not exceed the default column width
Environment