fix: strip trailing newlines from show line output#500
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an output-normalization issue in the CLI where gto show single-line outputs could contain an extra blank line when the underlying value already ended with \r/\n, by stripping trailing newline characters before emitting via Click.
Changes:
- Add a small helper to strip trailing
\r/\nfrom values printed viaformat_echo(..., "line")andformat_echo(..., "lines"). - Update
format_echoto use the normalization helper for theline/linesformats. - Add a regression test covering
gto show --refandgto show --versionwhen returned values include trailing CR/LF.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
gto/utils.py |
Normalizes line/lines output by stripping trailing CR/LF before click.echo, preventing extra blank lines. |
tests/test_cli.py |
Adds regression coverage ensuring gto show --ref/--version emits exactly one trailing newline even if values contain CR/LF. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@w3lld1 please TAL / resolve and fix. Thanks for the contribution. |
d5dc743 to
058e029
Compare
|
Rebased this onto current main, resolved the conflict with the adjacent show-version test, and fixed the ruff-format failure. Local validation now passes: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Fixes #454 by normalizing
gto showsingle-line outputs so tag/ref/version values that already contain trailing CR/LF characters do not produce an extra blank line in CLI output.Changes
\r/\nfrom values emitted throughformat_echo(..., \"line\")andformat_echo(..., \"lines\").gto show --refandgto show --versionwhen returned values contain trailing newlines.Verification
pytest tests/test_cli.py::test_show_line_flags_strip_value_newlines tests/test_cli.py::test_commands tests/test_cli.py::test_show_ref_flag_not_applicable -qpytest -qpython -m py_compile gto/*.pygit diff --check