simplify checkpoint policy pre-push sync · Entire
simplify checkpoint policy pre-push sync
e5feacd→main·
pfleidi·2w ago·3 files·+8 added/-11 removed
Policy sync is advisory now, so keep the helper focused on sync and warning side effects instead of returning a push gate.
Sessions
b36a51f8fc56View transcript
[?
Enforce Checkpoint Policies in CLICodex·GPT-5.5·5 steps](/content/gh/entireio/cli/session/019f05ad-eea0-7202-a508-ec34d069a2d2#timeline-b36a51f8fc56/index.html)
Changes
3
cmd/entire/cli/strategy
Mcheckpoint_policy.go+5/-6
Mcheckpoint_policy_test.go+2/-2
Mmanual_commit_push.go+1/-3
24 unmodified lines
25
26
27
28
28
29
30
31
32
33
34
34
35
36
37
2 unmodified lines
40
41
42
43
43
44
45
46
3 unmodified lines
50
51
52
53
53
54
55
56
57
57
58
59
60
60
61
62
24 unmodified lines
return state.Policy, true
}
func syncCheckpointPolicyForPrePush(ctx context.Context, ps pushSettings) bool {
func syncCheckpointPolicyForPrePush(ctx context.Context, ps pushSettings) {
repo, err := OpenRepository(ctx)
if err != nil {
logging.Warn(ctx, "checkpoint policy pre-push: failed to open repository; allowing checkpoint push",
slog.String("error", err.Error()),
)
return true
return
}
defer repo.Close()
2 unmodified lines
logging.Warn(ctx, "checkpoint policy pre-push: failed to resolve worktree root; allowing checkpoint push",
slog.String("error", err.Error()),
)
return true
return
}
target := checkpointpolicy.Target{Remote: ps.pushTarget(), Dir: dir}
state, err := checkpointpolicy.Sync(ctx, repo, target)
3 unmodified lines
if readErr == nil {
warnIfCheckpointPolicyNeedsUpgrade(ctx, localState.Policy)
}
return true
return
}
if state.Source == checkpointpolicy.SourceLocalDiverged {
warnOrLogCheckpointPolicyDiverged(ctx, state)
return true
return
}
warnIfCheckpointPolicyNeedsUpgrade(ctx, state.Policy)
return true
}
func warnOrLogCheckpointPolicySyncFailure(ctx context.Context, err error) {
Mcmd/entire/cli/strategy/checkpoint_policy.go+5/-6
234 unmodified lines
235
236
237
238
238
239
240
241
241
242
243
244
234 unmodified lines
t.Chdir(workDir)
paths.ClearWorktreeRootCache()
require.True(t, syncCheckpointPolicyForPrePush(context.Background(), pushSettings{
syncCheckpointPolicyForPrePush(context.Background(), pushSettings{
remote: "origin",
checkpointURL: pushTargetDir,
}))
})
state, err := checkpointpolicy.ReadLocal(t.Context(), repo)
require.NoError(t, err)
require.Equal(t, targetHash, state.Hash)
Mcmd/entire/cli/strategy/checkpoint_policy_test.go+2/-2
43 unmodified lines
44
45
46
47
48
49
47
48
49
50
43 unmodified lines
}
refs := checkpoint.ResolveRefs(ctx)
if !syncCheckpointPolicyForPrePush(ctx, ps) {
return nil
}
syncCheckpointPolicyForPrePush(ctx, ps)
// OPF pre-push rewrite: if OPF is configured, resolve the user's
// decision (env > settings > prompt > non-TTY auto-run), then
Mcmd/entire/cli/strategy/manual_commit_push.go+1/-3