Skip to content

feat: add IdStrategy variant for commit-OID-keyed entity refs #6

@jdc-pub

Description

@jdc-pub

Problem

Ledger::create assigns a ref ID via IdStrategy, but none of the current
variants allow the ref to be named after the OID of its own initial commit.

The desired layout is refs/forge/issue/<initial-commit-oid> — where the ref
suffix is the OID of the commit that create writes. This OID is the permanent,
stable identity of the entity; it never changes even as the ref tip advances
with edits.

Current workaround

In git-forge we bypass Ledger::create entirely and write the commit + ref
manually:

let commit_oid = repo.commit(None, &sig, &sig, message, &tree, &[])?;
let ref_name = format!("refs/forge/issue/{commit_oid}");
repo.reference(&ref_name, commit_oid, false, "create issue")?;

This duplicates internal Ledger logic and bypasses the abstraction.

Proposed fix

Add a new variant to IdStrategy:

/// Name the record's ref after the OID of the commit that `create` writes.
CommitOid,

Inside Ledger::create, build the tree and commit first (with no ref), then
use the resulting commit OID as the record ID and create the ref in a second
step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions