~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

repo commit reads the repository once, a round trip less

Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:client/commit-reads-once
.changeset/commit-reads-once.mdnew+7−0
@@ -0,0 +1,7 @@
---
default: patch
---
# `repo commit` reads the repository once
`knotless repo commit`, and the MCP tool `repo_commit`, read the repository's record and refs once before committing, where they read them twice: every commit made without a checkout waits for one round trip to the PDS less.
crates/knotless/src/commit.rs+8−2
@@ -107,7 +107,7 @@ async fn signed(ctx: &Ctx, spec: &Spec, me: &Session) -> Spec {
}
pub async fn commit(ctx: &Ctx, url: &RepoUrl, spec: &Spec) -> Result<Committed> {
let remote = Remote::locate(ctx, url).await?.0;
let (remote, read) = Remote::locate(ctx, url).await?;
if let Some(me) = session::reader(ctx, &remote.identity).await
&& (me.did != remote.did() || spec.via_gateway)
{
@@ -117,9 +117,15 @@ pub async fn commit(ctx: &Ctx, url: &RepoUrl, spec: &Spec) -> Result<Committed>
let spec = &signed(ctx, spec, &session).await;
let refname = format!("refs/heads/{}", spec.branch);
let mut attempts = 0;
// The first attempt builds on what locating the repository read; a
// replay reads it again.
let mut read = Some(read);
loop {
attempts += 1;
let snap = remote.snapshot(ctx).await?;
let snap = match read.take() {
Some(snap) => snap,
None => remote.snapshot(ctx).await?,
};
let (git, _scratch) = match snap.key() {
Some(key) => {
let mirror = Mirror::of(ctx, &remote, key).await?;