mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
feat(version): add commitDate to build stamp and version_info
This commit is contained in:
parent
5bc44cb8c3
commit
17c7dfea8c
7 changed files with 56 additions and 39 deletions
|
|
@ -91,42 +91,33 @@ def test_get_git_commit_output_format_identical_between_sources(tmp_path):
|
|||
assert all(c in "0123456789abcdef" for c in live)
|
||||
|
||||
|
||||
def test_get_git_commit_date_uses_live_git(tmp_path):
|
||||
"""Source install: ``git log -1 --format=%cd --date=short`` returns the date."""
|
||||
def test_get_git_commit_date_uses_version_info(tmp_path):
|
||||
"""Source install: version_info carries the commit date from live git."""
|
||||
from hermes_cli import dump
|
||||
|
||||
repo_dir = tmp_path / "repo"
|
||||
repo_dir.mkdir()
|
||||
|
||||
git_result = MagicMock(returncode=0, stdout="2026-06-17\n")
|
||||
with patch("hermes_cli.dump.subprocess.run", return_value=git_result):
|
||||
with patch("hermes_cli.version_info._resolve_stamp_file", lambda: None), \
|
||||
patch("hermes_cli.version_info._resolve_repo_dir", lambda: repo_dir), \
|
||||
patch("hermes_cli.version_info._git_version_info",
|
||||
return_value=VersionInfo("0.19.0", "0.19.0+3", 3, "deadbeef" * 5, "main", "git", False, 1718662620)):
|
||||
_reset_version_info_cache()
|
||||
date = dump._get_git_commit_date(repo_dir)
|
||||
|
||||
assert date == "2026-06-17"
|
||||
assert date == "2024-06-17"
|
||||
|
||||
|
||||
def test_get_git_commit_date_empty_when_git_fails(tmp_path):
|
||||
"""Docker image / pip wheel: no git → '' so the dump line drops the date."""
|
||||
def test_get_git_commit_date_empty_when_unknown(tmp_path):
|
||||
"""Docker/pip: no git, no stamp → '' so the dump line drops the date."""
|
||||
from hermes_cli import dump
|
||||
|
||||
repo_dir = tmp_path / "no-git-here"
|
||||
repo_dir.mkdir()
|
||||
|
||||
failed = MagicMock(returncode=128, stdout="")
|
||||
with patch("hermes_cli.dump.subprocess.run", return_value=failed):
|
||||
date = dump._get_git_commit_date(repo_dir)
|
||||
|
||||
assert date == ""
|
||||
|
||||
|
||||
def test_get_git_commit_date_empty_when_git_raises(tmp_path):
|
||||
"""git binary missing → '' (no crash, suffix simply omitted)."""
|
||||
from hermes_cli import dump
|
||||
|
||||
repo_dir = tmp_path / "repo"
|
||||
repo_dir.mkdir()
|
||||
|
||||
with patch("hermes_cli.dump.subprocess.run", side_effect=FileNotFoundError("git")):
|
||||
with patch("hermes_cli.version_info._resolve_stamp_file", lambda: None), \
|
||||
patch("hermes_cli.version_info._resolve_repo_dir", lambda: None):
|
||||
_reset_version_info_cache()
|
||||
date = dump._get_git_commit_date(repo_dir)
|
||||
|
||||
assert date == ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue