Add RefScope.AllRefs to broaden mirroring beyond branches and tags · Entire

Add RefScope.AllRefs to broaden mirroring beyond branches and tags

6814963→main·

Soph·2mo ago·12 files·+193 added/-28 removed

Introduce a third RefKindOther for refs/* namespaces outside refs/heads/ and refs/tags/ (notes, pulls, replace, custom). Validation accepts those mappings only when the new RefScope.AllRefs flag is set; without it the existing strict branch/tag flow stays loud about unsupported refs.

When AllRefs is set, BuildDesiredRefs picks up every refs/* on the source, RefPrefixes collapses to a single "refs/" so v2 ls-refs returns the broader set, and prune treats unmanaged other-kind target refs as delete candidates. Other-kind refs follow branch-style semantics (fast-forward / force) in PlanRef, and the existing relay paths fall through to the materialized push because their kind switches default to "unsupported", which is the right behavior for a first cut.

This wires the field through the public RefScope, ProbeRequest, internalbridge, syncer.Config, and the unstable client. CLI surface and best-effort failure handling come in follow-up commits.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Sessions

82d903ebce8dView transcript

Changes

12

102 unmodified lines

103
104
105
106
107
108
109
45 unmodified lines

155
156
157
157
158
159
160
161
12 unmodified lines

174
175
176
176
177
178
179
180
39 unmodified lines

220
221
222
223
224
225
226

102 unmodified lines

targetAuth,
        internalbridge.ProtocolMode(req.Protocol),
        req.IncludeTags,
        req.AllRefs,
        req.CollectStats,
        c.httpClient,
    ), nil
45 unmodified lines

if _, err := validation.NormalizeProtocolMode(string(r.Policy.Protocol)); err != nil {
        return fmt.Errorf("normalize protocol: %w", err)
    }
    if _, err := validation.ValidateMappings(validationMappings(r.Scope.Mappings)); err != nil {
        return fmt.Errorf("validate mappings: %w", err)
    }
    if _, err := validation.ValidateMappings(validationMappings(r.Scope.Mappings), r.Scope.AllRefs); err != nil {
        return fmt.Errorf("validate mappings: %w", err)
    }
    return nil

12 unmodified lines

39 unmodified lines

return internalbridge.RefScope{
        Branches: append([]string(nil), scope.Branches...),
        Mappings: mappings,
        AllRefs:  scope.AllRefs,
    }
}