Skip to content

fix: gto --plain doesnt truncate wide versions#490

Open
ZivotJeKrasny wants to merge 1 commit intoiterative:mainfrom
ZivotJeKrasny:fix_489
Open

fix: gto --plain doesnt truncate wide versions#490
ZivotJeKrasny wants to merge 1 commit intoiterative:mainfrom
ZivotJeKrasny:fix_489

Conversation

@ZivotJeKrasny
Copy link
Copy Markdown

Fixes #489

Copilot AI review requested due to automatic review settings March 18, 2026 23:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes issue #489 where gto show --plain (global registry view) could truncate “wide” SemVer strings (e.g. v0.100.0v0.100.), breaking machine parsing of CLI output.

Changes:

  • Update _show_registry() to truncate only real 40-char hex SHAs (via is_hexsha()), not arbitrary strings.
  • Add regression tests covering wide SemVer in global --plain output and _show_registry() table output.
  • Add an additional test intended to ensure hexsha truncation still occurs (currently incomplete; see comments).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
gto/api.py Fixes truncation logic by guarding truncation with is_hexsha() in _show_registry().
tests/test_cli.py Adds CLI regression test asserting global gto show --plain output preserves wide SemVer.
tests/test_api.py Adds API-level regression test for _show_registry() wide SemVer; adds a hexsha truncation “sanity” test that currently doesn’t assert truncation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 12 to +14
from gto.cli import app
from gto.exceptions import GTOException
import gto as gto_lib
Comment on lines +621 to +632
"""Sanity check: actual hex SHAs in stage columns are still truncated."""
version = "v0.0.1"
gto.api.register(tmp_dir, "model", "HEAD", version)
# assign using raw commit hexsha as version (non-semver) via API internals
# — we verify via the stage dict that real hexshas are truncated while
# semver strings are left intact.
rows, _ = gto.api._show_registry(tmp_dir, table=True, truncate_hexsha=True)
model_row = next(r for r in rows if "model" in r["name"])
# The semver-registered version must never be truncated
assert model_row["latest"] == version


@@ -319,7 +319,7 @@ def _show_registry(
"""Show current registry state"""

def format_hexsha(hexsha):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how / where is called outside?

It seems the problem here is that we pass something that is not hash into a function that is named format_hexsha . T

This guard should be outside of this function.

Copy link
Copy Markdown
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. Please review comment's address each meaningfully. Probably a bit broader refactoring is needed here.

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.

gto show --plain truncates latest version values in global output table (breaks CLI parsing for multi-digit semver)

3 participants