Minimize code comments in milestone-2 diff · Entire
Minimize code comments in milestone-2 diff
fd8c18a→main·
computermode·1mo ago·7 files·+15 added/-33 removed
Trim the comments added by this branch to the load-bearing "why", dropping restatement and obvious narration. No behavior change.
- committed_refs.go: drop the PrimaryFetchableFromOrigin invariant note (the test row covers it); keep why v1.1 is pushed. - manual_commit_push.go: remove the self-evident call-site comment; shorten the refreshMirrorBeforePush docstring. - committed_refs_test.go: tighten the two case comments (keep the non-branch / Read != Primary reason). - remote_operations_test.go: shorten the docstring and tip-check comment; drop the comment narrating the v1-branch assertion. - paths.go: shorten the MetadataRefName doc back toward its original length. - push_common_test.go, v1_custom_ref_mirror_test.go: shorten test docstrings.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
4a6ba736a804View transcript
Changes
7
cmd/entire/cli
checkpoint
Mcommitted_refs.go+2/-4
Mcommitted_refs_test.go+3/-5
integration_test
Mremote_operations_test.go+3/-8
paths
Mpaths.go+2/-4
strategy
Mmanual_commit_push.go+2/-7
Mpush_common_test.go+1/-2
Mv1_custom_ref_mirror_test.go+2/-3
68 unmodified lines
69
70
71
72
73
74
75
72
73
74
75
76
68 unmodified lines
custom := plumbing.ReferenceName(paths.MetadataRefName)
refs.Read = custom
refs.Mirror = custom
// Push v1.1 alongside v1 so the new ref exists on the remote before a
// later milestone flips it to Primary. Primary stays v1, so
// PrimaryFetchableFromOrigin (which requires Primary.IsBranch) is
// unaffected by adding the non-branch v1.1 ref here.
// Push v1.1 alongside v1 so it exists on the remote before a later
// milestone flips it to Primary.
refs.Push = append(refs.Push, custom)
}
return refs
Mcmd/entire/cli/checkpoint/committed_refs.go+2/-4
76 unmodified lines
77
78
79
80
81
80
81
82
83
16 unmodified lines
100
101
102
104
105
106
103
104
105
106
107
76 unmodified lines
want bool
}{
{"v1 in push", CommittedRefs{Primary: v1, Push: []plumbing.ReferenceName{v1}}, true},
// The v1.1-push milestone topology: a non-branch v1.1 alongside the v1
// branch in Push must not change v1's origin-fetchability.
// Non-branch v1.1 alongside v1 in Push must not change v1's fetchability.
{"v1 primary, v1.1 also pushed", CommittedRefs{Primary: v1, Push: []plumbing.ReferenceName{v1, custom}}, true},
{"primary not in push", CommittedRefs{Primary: custom, Push: []plumbing.ReferenceName{v1}}, false},
{"empty push", CommittedRefs{Primary: v1, Push: nil}, false},
16 unmodified lines
want bool
}{
{"v1-only: reads target fetchable primary", CommittedRefs{Primary: v1, Read: v1, Push: []plumbing.ReferenceName{v1}}, true},
// v1.1-push milestone: v1.1 is pushed, but it's a non-branch ref with no
// origin-tracking shadow and Read != Primary, so reads still cannot
// bootstrap from origin.
// v1.1 is pushed but is a non-branch ref (no origin shadow) and
// Read != Primary, so reads still can't bootstrap from origin.
{"v1.1 pushed but reads target mirror", CommittedRefs{Primary: v1, Read: custom, Mirror: custom, Push: []plumbing.ReferenceName{v1, custom}}, false},
{"reads target primary but primary not pushed", CommittedRefs{Primary: v1, Read: v1, Push: nil}, false},
}
Mcmd/entire/cli/checkpoint/committed_refs_test.go+3/-5
68 unmodified lines
69
70
71
72
73
74
72
73
74
75
76
79
80
77
78
79
80
16 unmodified lines
97
98
99
103
100
101
102
103
108
109
104
105
106
107
68 unmodified lines
// TestPrePush_PushesV1CustomRefWhenOptedIn verifies that with
// checkpoints_version "1.1", PrePush pushes refs/entire/checkpoints/v1.1
// alongside the v1 branch, and that the pushed mirror matches the v1 tip on
// the remote.
// checkpoints_version "1.1", PrePush pushes the v1.1 ref to the remote at the v1 tip.
func TestPrePush_PushesV1CustomRefWhenOptedIn(t *testing.T) {
t.Parallel()
env := NewFeatureBranchEnv(t)
// Opt into v1.1 before any session activity so condensation mirrors v1.1
// and the resolver puts v1.1 in the push set.
// Opt in before session activity so condensation mirrors v1.1.
env.PatchSettings(map[string]any{
"strategy_options": map[string]any{"checkpoints_version": "1.1"},
})
16 unmodified lines
env.RunPrePush("origin")
// The v1 branch still pushes as before.
if !env.BranchExistsOnRemote(bareDir, paths.MetadataBranchName) {
t.Fatalf("%s should exist on bare remote after PrePush", paths.MetadataBranchName)
}
// The v1.1 ref must now exist on the remote and point at the same commit as
// the v1 branch (revParse fails the test if the v1.1 ref is absent).
// v1.1 must exist on the remote at the v1 tip (revParse fails if absent).
remoteV1 := revParse(t, bareDir, "refs/heads/"+paths.MetadataBranchName)
remoteCustom := revParse(t, bareDir, paths.MetadataRefName)
if remoteV1 != remoteCustom {
Mcmd/entire/cli/integration_test/remote_operations_test.go+3/-8
41 unmodified lines
42
43
44
45
46
47
48
45
46
47
48
49
41 unmodified lines
// when checkpoints_version is "1.1". It lives under refs/entire/ (not
// refs/heads/) so it stays invisible to `git branch -a` and is not pulled by a
// default `git clone`. v1 remains the source of truth; this ref mirrors it.
// When v1.1 is enabled, committed reads resolve against this ref as-is, active
// v1 write/fetch paths update the mirror, and PrePush pushes it to the remote
// alongside v1. As a non-branch ref it gets no origin-tracking shadow, so reads
// still do not bootstrap it from origin.
// When v1.1 is enabled, committed reads resolve against this ref, active v1
// write/fetch paths update the mirror, and PrePush pushes it alongside v1.
const MetadataRefName = "refs/entire/checkpoints/v1.1"
// TrailsBranchName is the orphan branch used to store trail metadata.
Mcmd/entire/cli/paths/paths.go+2/-4
32 unmodified lines
33
34
35
36
37
38
36
37
38
9 unmodified lines
48
49
50
54
55
56
57
51
52
53
54
55
32 unmodified lines
refs := checkpoint.ResolveCommittedRefs(ctx)
// Re-point the mirror at the primary's current tip before pushing, so we
// publish the primary's state and not a tip left stale by an earlier
// best-effort advance that failed. Skipped when no mirror is configured.
refreshMirrorBeforePush(ctx, refs)
// Thread the span's context into the push so the network push and any
9 unmodified lines
return nil
}
// refreshMirrorBeforePush advances the configured mirror to the primary tip
// just before pushing. Best-effort: a failure to open the repo or refresh the
// mirror is logged and never blocks the push (the pre-push hook is wrapped in
// `|| true`). No-op when the topology has no mirror.
// refreshMirrorBeforePush advances the mirror to the primary tip before
// pushing. Best-effort: failures are logged, never blocking the push.
func refreshMirrorBeforePush(ctx context.Context, refs checkpoint.CommittedRefs) {
if !refs.HasMirror() {
return
}
Mcmd/entire/cli/strategy/manual_commit_push.go+2/-7
145 unmodified lines
146
147
148
149
150
149
150
151
152
145 unmodified lines
// TestPushRefIfNeeded_NonBranchRef verifies that pushRefIfNeeded accepts
// arbitrary refs (not just branches under refs/heads) and pushes them with a
// generic refspec — e.g. refs/entire/checkpoints/v1.1, which the resolver adds
// to CommittedRefs.Push when checkpoints_version is "1.1".
// generic refspec, e.g. refs/entire/checkpoints/v1.1.
// Not parallel: uses t.Chdir() (required for OpenRepository).
func TestPushRefIfNeeded_NonBranchRef(t *testing.T) {
Mcmd/entire/cli/strategy/push_common_test.go+1/-2
536 unmodified lines
537
538
539
540
541
542
540
541
542
543
544
536 unmodified lines
}
// TestPrePush_PushesV1CustomRefWhenOptedIn proves the v1.1-push milestone: with
// the mirror opted in and both refs present locally, pre-push pushes the v1
// branch and the v1 custom ref alongside it.
// TestPrePush_PushesV1CustomRefWhenOptedIn proves that with the mirror opted
// in, pre-push pushes the v1 branch and the v1 custom ref alongside it.
// Not parallel: uses t.Chdir().
func TestPrePush_PushesV1CustomRefWhenOptedIn(t *testing.T) {
Mcmd/entire/cli/strategy/v1_custom_ref_mirror_test.go+2/-3