fix: list_refs falls back to git mirror when vcs store is empty The listRefs handler was reading only from the panproto-vcs FsStore, which is empty when the repo was pushed via raw git (not git-remote-cospan). Now it falls back to listing refs from the persistent git mirror, which always has refs after any git push.

Author: Aaron Steven White
Commit 13a21248692b2a55f542fb0f173338c4711c9e49
Parent: 31fc2aa167
Structural diff unavailable

These commits were pushed via plain git push, so no pre-parsed schemas are available. Install git-remote-cospan and re-push via panproto:// to see scope-level changes, breaking change detection, and semantic diffs.

brew install panproto/tap/git-remote-cospan
1 file changed +38 -8
@@ -18,14 +18,44 @@ pub async fn list_refs(
1818     Query(params): Query<ListRefsParams>,
1919 ) -> Result<Json<serde_json::Value>, NodeError> {
2020     let store = state.store.lock().await;
21-    let refs = store
22-        .list_refs(&params.did, &params.repo)
23-        .map_err(|e| NodeError::Internal(format!("store error: {e}")))?;
2421 
25-    let refs_json: Vec<serde_json::Value> = refs
26-        .into_iter()
27-        .map(|(name, id)| serde_json::json!({ "ref": name, "target": id.to_string() }))
28-        .collect();
22+    // Try panproto-vcs store first (has refs from git-remote-cospan push).
23+    if let Ok(refs) = store.list_refs(&params.did, &params.repo) {
24+        if !refs.is_empty() {
25+            let refs_json: Vec<serde_json::Value> = refs
26+                .into_iter()
27+                .map(|(name, id)| {
28+                    serde_json::json!({ "ref": name, "target": id.to_string() })
29+                })
30+                .collect();
31+            return Ok(Json(serde_json::json!({ "refs": refs_json })));
32+        }
33+    }
2934 
30-    Ok(Json(serde_json::json!({ "refs": refs_json })))
35+    // Fall back to git mirror refs (from raw git push).
36+    if store.has_git_mirror(&params.did, &params.repo) {
37+        let mirror = store
38+            .open_or_init_git_mirror(&params.did, &params.repo)
39+            .map_err(|e| NodeError::Internal(format!("open mirror: {e}")))?;
40+        drop(store);
41+
42+        let mut refs_json: Vec<serde_json::Value> = Vec::new();
43+        let references = mirror
44+            .references()
45+            .map_err(|e| NodeError::Internal(format!("list refs: {e}")))?;
46+
47+        for r in references.flatten() {
48+            let Some(name) = r.name() else { continue };
49+            let Some(oid) = r.target() else { continue };
50+            refs_json.push(serde_json::json!({
51+                "ref": name,
52+                "target": oid.to_string(),
53+            }));
54+        }
55+
56+        return Ok(Json(serde_json::json!({ "refs": refs_json })));
57+    }
58+
59+    drop(store);
60+    Ok(Json(serde_json::json!({ "refs": [] })))
3161 }
cospan · schematic version control on atproto built on AT Protocol