refactor(checkpoint): drop deprecated skipDefaultUpdate stamp · Entire
refactor(checkpoint): drop deprecated skipDefaultUpdate stamp
740b799→main·
pjbgf·3d ago·3 files·+27 added/-42 removed
remote.git fetch --all and
git remote update. Stamp only skipFetchAll and stop writing the
redundant key, and tighten the integration git-config guard accordingly.
Assisted-by: Claude Opus 4.8 noreply@anthropic.com Signed-off-by: Paulo Gomes paulo@entire.io
Sessions
01KXGDNA3R69R5QXQQ7RTT10ZHView transcript
Changes
3
cmd/entire/cli
checkpoint/remote
Mgit.go+22/-26
Mgit_test.go+2/-12
integration_test
Mtestenv.go+3/-4
95 unmodified lines
96
97
98
99
100
101
99
100
101
102
103
104
44 unmodified lines
149
150
151
152
153
154
155
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
95 unmodified lines
// (remote.<url>.*) so it can lazy-fetch filtered-out objects later. That
// section also turns the URL into a phantom remote that `git fetch --all`
// and `git remote update` keep dialing. When this fetch is the one creating
// the section, stamp skipFetchAll/skipDefaultUpdate so bulk fetches skip our
// adhoc remote. Remotes that already existed are left untouched so we never
// rewrite the user's config.
// the section, stamp skipFetchAll so bulk fetches skip our adhoc remote.
// Remotes that already existed are left untouched so we never rewrite the
// user's config.
var stampURL string
var stampCandidate, existedBefore bool
if filtered && IsURL(opts.Remote) {
44 unmodified lines
}
}
// markRemoteSkipped stamps skipFetchAll/skipDefaultUpdate on a URL-keyed remote
// section so `git fetch --all` and `git remote update` skip it. Called only for
// remotes this fetch just created, so an adhoc checkpoint URL never lingers as a
// phantom remote that bulk fetches keep dialing.
// markRemoteSkipped stamps skipFetchAll on a URL-keyed remote section so
// `git fetch --all` and `git remote update` skip it. Called only for remotes
// this fetch just created, so an adhoc checkpoint URL never lingers as a phantom
// remote that bulk fetches keep dialing.
// Best-effort: the git config write is not worth failing the fetch over, so
// failures only log.
func markRemoteSkipped(ctx context.Context, dir, url string) {
for _, key := range []string{"skipFetchAll", "skipDefaultUpdate"} {
fullKey := "remote." + url + "." + key
cmd := exec.CommandContext(ctx, "git", "config", "--local", fullKey, "true")
if dir != "" {
cmd.Dir = dir
}
if out, cfgErr := cmd.CombinedOutput(); cfgErr != nil {
redactedURL := RedactURL(url)
// The output can echo the key, which embeds the URL — and a URL
// can carry credentials. Redact before logging.
msg := strings.TrimSpace(strings.ReplaceAll(string(out), url, redactedURL))
logging.Warn(ctx, "failed to mark remote config entry as skipped for bulk fetches",
slog.String("url", redactedURL),
slog.String("key", key),
slog.String("output", msg),
slog.String("error", cfgErr.Error()),
)
return
}
fullKey := "remote." + url + ".skipFetchAll"
cmd := exec.CommandContext(ctx, "git", "config", "--local", fullKey, "true")
if dir != "" {
cmd.Dir = dir
}
if out, cfgErr := cmd.CombinedOutput(); cfgErr != nil {
redactedURL := RedactURL(url)
// The output can echo the key, which embeds the URL — and a URL can
// carry credentials. Redact before logging.
msg := strings.TrimSpace(strings.ReplaceAll(string(out), url, redactedURL))
logging.Warn(ctx, "failed to mark remote config entry as skipped for bulk fetches",
slog.String("url", redactedURL),
slog.String("output", msg),
slog.String("error", cfgErr.Error()),
)
}
}
}
Mcmd/entire/cli/checkpoint/remote/git.go+22/-26
863 unmodified lines
864 865 866 867 868 867 868 869 50 unmodified lines
920 921 922 925 926 923 924 925 37 unmodified lines
963 964 965 970 966 967 968 47 unmodified lines
1016 1017 1018 1024 1025 1019 1020 1028 1029 1021 1022 1023 1024 1025 4 unmodified lines
1030 1031 1032 1040 1033 1034 1035 52 unmodified lines
1088 1089 1090 1099 1100 1091
863 unmodified lines
assert.True(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipFetchAll"), "URL-keyed promisor entry should be excluded from git fetch --all") assert.True(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipDefaultUpdate"), "URL-keyed promisor entry should be excluded from git remote update")
// git fetch --all must no longer dial the phantom entry: with the // checkpoint repo gone, --all only succeeds if the URL-keyed entry is 50 unmodified lines
"git records the promisor section even when the fetch fails") assert.True(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipFetchAll"), "a phantom remote left by a failed fetch must still be stamped") assert.True(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipDefaultUpdate"), "a phantom remote left by a failed fetch must still be stamped") }
// TestFetch_UnfilteredFetchDoesNotCreateConfigSection verifies the stamp is 37 unmodified lines
assert.False(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".promisor")) assert.False(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipFetchAll")) assert.False(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipDefaultUpdate")) }
// TestFetch_ExistingURLRemoteNotReStamped verifies we only stamp remotes we 47 unmodified lines
assert.False(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipFetchAll"), "a remote that already existed must not be stamped") assert.False(t, gitConfigBool(ctx, cloneDir, "remote."+fetchURL+".skipDefaultUpdate"), "a remote that already existed must not be stamped") }
// TestMarkRemoteSkipped_SetsBothKeys verifies the helper stamps both skip keys. func TestMarkRemoteSkipped_SetsBothKeys(t *testing.T) { // TestMarkRemoteSkipped_SetsSkipFetchAll verifies the helper stamps skipFetchAll. func TestMarkRemoteSkipped_SetsSkipFetchAll(t *testing.T) {
t.Parallel() ctx := context.Background()
4 unmodified lines
markRemoteSkipped(ctx, repoDir, url)
assert.True(t, gitConfigBool(ctx, repoDir, "remote."+url+".skipFetchAll")) assert.True(t, gitConfigBool(ctx, repoDir, "remote."+url+".skipDefaultUpdate")) }
// TestGitRemoteSectionExists reports true only once a remote.
assert.True(t, gitConfigBool(context.Background(), repoDir, "remote."+url+".skipFetchAll"), "stamp must land even though the parent context is cancelled") assert.True(t, gitConfigBool(context.Background(), repoDir, "remote."+url+".skipDefaultUpdate"), "stamp must land even though the parent context is cancelled") }