gabriel / musehub public
commit_fixtures.py python
24 lines 948 B
Raw
sha256:c62240d36e803460a80726fd25ffe9b5c51d9e0193c1f77753e157dc8d5d1d39 fix(wire): bind every pushed commit's snapshot and the bran… Opus 5.5 minor ⚠ breaking 3 days ago
1 """Wire commit records whose commit_id reproduces from their own fields.
2
3 Push ingest refuses a commit whose id does not reproduce, so tests that push
4 commits must build ids the way a client does, not from an arbitrary hash.
5 """
6 from __future__ import annotations
7
8 from muse.core.ids import hash_commit
9 from musehub.types.json_types import JSONObject
10
11
12 def with_reproducible_id(record: JSONObject) -> JSONObject:
13 """Return *record* with ``commit_id`` set to the id its fields hash to."""
14 text = lambda key: str(record.get(key) or "")
15 parents = [text(k) for k in ("parent_commit_id", "parent2_commit_id") if record.get(k)]
16 commit_id = hash_commit(
17 parent_ids=parents,
18 snapshot_id=text("snapshot_id"),
19 message=text("message"),
20 committed_at_iso=text("committed_at"),
21 author=text("author"),
22 signer_public_key=text("signer_public_key"),
23 )
24 return {**record, "commit_id": commit_id}
File History 3 commits
sha256:c62240d36e803460a80726fd25ffe9b5c51d9e0193c1f77753e157dc8d5d1d39 fix(wire): bind every pushed commit's snapshot and the bran… Opus 5.5 minor ⚠ 3 days ago
sha256:383b9b15b1a7c18348bf797dbec252b8842199567b4b04371578fedd5f7891d4 merge: integrate push-ingest commit verification into dev Opus 5.5 minor ⚠ 11 days ago
sha256:a4d6b38221ff81ce17b43d47240f441c45140d63c575f98273c66c0df132c388 fix(push): verify commit records at ingest and reconcile du… Opus 5.5 minor ⚠ 11 days ago