MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / upsert_commit_session

Function upsert_commit_session

src/sessions/git_correlation.rs:579–604  ·  view source on GitHub ↗

Inserts one commit attribution row; existing rows win (idempotent for re-runs of live attribution and the backfill command). Returns `true` when a new row was inserted.

(
    conn: &Connection,
    record: &CommitSessionRecord,
)

Source from the content-addressed store, hash-verified

577/// re-runs of live attribution and the backfill command). Returns `true`
578/// when a new row was inserted.
579pub(crate) async fn upsert_commit_session(
580 conn: &Connection,
581 record: &CommitSessionRecord,
582) -> Result<bool, GitCorrelationError> {
583 let worktree = record.worktree.as_deref().map(normalize_worktree);
584 let inserted = conn
585 .execute(
586 "INSERT OR IGNORE INTO commit_sessions (
587 commit_sha, provider, session_id, branch, worktree,
588 committed_at, span_overlap_kind, span_id
589 )
590 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
591 params![
592 record.commit_sha.as_str(),
593 record.provider.as_str(),
594 record.session_id.as_str(),
595 opt_text(record.branch.as_deref()),
596 opt_text(worktree.as_deref()),
597 record.committed_at,
598 record.span_overlap_kind.as_str(),
599 record.span_id.map_or(Value::Null, Value::Integer),
600 ],
601 )
602 .await?;
603 Ok(inserted > 0)
604}
605
606mod attribution;
607pub(crate) use attribution::run_commit_attribution_sweep;

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected