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
Mclient.go+4/-2
internal
planner
Mplanner.go+25/-1
Mplanner_test.go+67/-6
Mtypes.go+16/-3
syncer
Mgit_http_backend_test.go+2/-2
Msyncer.go+6/-3
validation
Mvalidation.go+25/-10
Mvalidation_test.go+30
internalbridge
Mconfig.go+4/-1
Mmodel.go+1
Mtypes.go+10
unstable
Mclient.go+3
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,
}
}