-
Notifications
You must be signed in to change notification settings - Fork 279
Fix checkpoint_remote silently falling back to origin on owner mismatch #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,39 +76,46 @@ func resolvePushSettings(ctx context.Context, pushRemoteName string) pushSetting | |||||||||
| return ps | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Get the push remote URL for protocol detection and fork detection | ||||||||||
| // Get the push remote URL for protocol detection | ||||||||||
| pushRemoteURL, err := getRemoteURL(ctx, pushRemoteName) | ||||||||||
| if err != nil { | ||||||||||
| fmt.Fprintf(os.Stderr, "[entire] Warning: checkpoint_remote is configured (%s) but could not get push remote URL: %v\n", config.Repo, err) | ||||||||||
| fmt.Fprintln(os.Stderr, "[entire] Checkpoints will be pushed to origin instead. Check your git remote configuration.") | ||||||||||
| logging.Debug(ctx, "checkpoint-remote: could not get push remote URL, skipping", | ||||||||||
| slog.String("remote", pushRemoteName), | ||||||||||
| slog.String("error", err.Error()), | ||||||||||
| ) | ||||||||||
| return ps | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Parse the push remote URL once for both fork detection and URL derivation | ||||||||||
| // Parse the push remote URL for protocol detection and URL derivation | ||||||||||
| pushInfo, err := parseGitRemoteURL(pushRemoteURL) | ||||||||||
| if err != nil { | ||||||||||
| fmt.Fprintf(os.Stderr, "[entire] Warning: checkpoint_remote is configured (%s) but could not parse push remote URL: %v\n", config.Repo, err) | ||||||||||
| fmt.Fprintln(os.Stderr, "[entire] Checkpoints will be pushed to origin instead. Check your git remote configuration.") | ||||||||||
|
Comment on lines
+94
to
+95
|
||||||||||
| logging.Warn(ctx, "checkpoint-remote: could not parse push remote URL", | ||||||||||
| slog.String("remote", pushRemoteName), | ||||||||||
| slog.String("error", err.Error()), | ||||||||||
| ) | ||||||||||
| return ps | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Fork detection: compare owners | ||||||||||
| // Log when push remote owner differs from checkpoint remote owner. | ||||||||||
| // Previously this skipped checkpoint_remote entirely (fork detection), | ||||||||||
| // but the user explicitly configured a checkpoint remote — respect that choice. | ||||||||||
|
Comment on lines
+104
to
+105
|
||||||||||
| // Previously this skipped checkpoint_remote entirely (fork detection), | |
| // but the user explicitly configured a checkpoint remote — respect that choice. | |
| // We no longer skip checkpoint_remote in this case (previously used for fork detection); | |
| // the user explicitly configured a checkpoint remote, so we always proceed with it. |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback warning says checkpoints will be pushed to "origin", but the code actually falls back to pushing to ps.remote (the remote passed into resolvePushSettings). Update the message to avoid implying a specific remote name.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -490,9 +490,10 @@ func TestResolvePushSettings_ForkDetection(t *testing.T) { | |
| t.Chdir(localDir) | ||
|
|
||
| ps := resolvePushSettings(ctx, "origin") | ||
| // Should fall back to origin since fork detected (alice != org) | ||
| assert.False(t, ps.hasCheckpointURL()) | ||
| assert.Equal(t, "origin", ps.pushTarget()) | ||
| // Should proceed with checkpoint remote even when owners differ — | ||
| // the user explicitly configured it, respect that choice. | ||
| assert.True(t, ps.hasCheckpointURL()) | ||
| assert.Equal(t, "git@github.com:org/checkpoints.git", ps.pushTarget()) | ||
|
Comment on lines
+493
to
+496
|
||
| assert.False(t, ps.pushDisabled) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback message hard-codes "origin", but resolvePushSettings is called with the remote name passed by the git pre-push hook (not always "origin"). This warning can mislead users when pushing to a different remote; consider referencing pushRemoteName (or wording like "your push remote") instead.