Document nested plan JSON fields · Entire

Document nested plan JSON fields

e55eb4d→main·

Soph·3mo ago·2 files·+21 added/-0 removed

Sessions

448fb22e8f55View transcript

Changes

2

111 unmodified lines

112
113
114
115
116
117
118
119
120
121
122

111 unmodified lines

The JSON interface is intentionally stable:

- keys use `snake_case`
- refs and hashes are serialized as strings, not raw byte arrays
- `probe` returns top-level keys such as `source_url`, `target_url`, `protocol`, `ref_prefixes`, `source_capabilities`, `target_capabilities`, `refs`, and `stats`
- `fetch` returns top-level keys such as `source_url`, `protocol`, `wants`, `haves`, `fetched_objects`, and `stats`
- `plan` and `sync` return top-level keys such as `plans`, `pushed`, `skipped`, `blocked`, `deleted`, `dry_run`, `protocol`, and `stats`
- each item in `plans` includes stable string fields such as `branch`, `source_ref`, `target_ref`, `source_hash`, `target_hash`, `kind`, `action`, and `reason`

Probe both source and target remotes to inspect source fetch capabilities and target `receive-pack` capabilities:

MREADME.md+2

109 unmodified lines

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

109 unmodified lines

if !ok || len(plans) == 0 {
        t.Fatalf("expected plan entries, got %#v", result["plans"])
    }
    plan0, ok := plans[0].(map[string]any)
    if !ok {
        t.Fatalf("unexpected first plan entry: %#v", plans[0])
    }
    if plan0["source_hash"] == nil || plan0["target_hash"] == nil {
        t.Fatalf("expected string hash fields in plan entry, got %#v", plan0)
    }
    if _, ok := plan0["source_hash"].(string); !ok {
        t.Fatalf("expected source_hash string, got %#v", plan0["source_hash"])
    }
    if _, ok := plan0["target_hash"].(string); !ok {
        t.Fatalf("expected target_hash string, got %#v", plan0["target_hash"])
    }
    if _, ok := plan0["source_ref"].(string); !ok {
        t.Fatalf("expected source_ref string, got %#v", plan0["source_ref"])
    }
    if _, ok := plan0["target_ref"].(string); !ok {
        t.Fatalf("expected target_ref string, got %#v", plan0["target_ref"])
    }
    if result["pushed"] != float64(0) {
        t.Fatalf("expected pushed=0, got %#v", result["pushed"])
    }

Mcmd/git-sync/main_test.go+19