b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
Build Skills Index / trigger-deploy (push) Waiting to run
CI / Deny unrelated histories (push) Has been skipped
CI / CI timing report (push) Blocked by required conditions
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / All required checks pass (push) Waiting to run
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""Session <-> workspace grouping key (hermes_state.workspace_key).
|
|
|
|
The key is what `hermes sessions list --workspace` groups/filters on. It is a
|
|
coarse workspace identity derived from fields already recorded on sessions
|
|
(git_repo_root, cwd) — no git shelling, no new columns. Branch is deliberately
|
|
NOT part of the key.
|
|
"""
|
|
|
|
from hermes_state import workspace_key
|
|
|
|
|
|
def test_repo_root_is_the_key_when_known():
|
|
row = {"git_repo_root": "/www/app", "cwd": "/www/app/src", "git_branch": "feat"}
|
|
assert workspace_key(row) == "/www/app"
|
|
|
|
|
|
def test_falls_back_to_cwd_for_non_git_sessions():
|
|
assert workspace_key({"cwd": "/work/notes"}) == "/work/notes"
|
|
assert workspace_key({"git_repo_root": "", "cwd": "/work/notes"}) == "/work/notes"
|
|
|
|
|
|
def test_none_when_unbound():
|
|
assert workspace_key({}) is None
|
|
assert workspace_key({"cwd": "", "git_repo_root": ""}) is None
|
|
assert workspace_key({"cwd": " "}) is None
|
|
|
|
|
|
def test_branch_does_not_affect_the_key():
|
|
# Two sessions on the same repo, different branches, group together.
|
|
a = {"git_repo_root": "/www/app", "git_branch": "main"}
|
|
b = {"git_repo_root": "/www/app", "git_branch": "feature-x"}
|
|
assert workspace_key(a) == workspace_key(b) == "/www/app"
|
|
|
|
|
|
def test_repo_root_wins_over_a_differing_cwd():
|
|
# A worktree/subdir session still groups under its repo root, not its cwd.
|
|
row = {"git_repo_root": "/www/app", "cwd": "/www/app/.worktrees/x"}
|
|
assert workspace_key(row) == "/www/app"
|