refactor: Remove deprecated fetchAndRebaseInWorktree (bd-kkka)
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1378
.beads/issues.jsonl
1378
.beads/issues.jsonl
File diff suppressed because one or more lines are too long
@@ -745,7 +745,6 @@ func isNonFastForwardError(output string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// contentMergeRecovery performs a content-level merge when push fails due to divergence.
|
// contentMergeRecovery performs a content-level merge when push fails due to divergence.
|
||||||
// This replaces the old fetchAndRebaseInWorktree which used git rebase (text-level).
|
|
||||||
//
|
//
|
||||||
// The problem with git rebase: it replays commits textually, which can resurrect
|
// The problem with git rebase: it replays commits textually, which can resurrect
|
||||||
// tombstones. For example, if remote has a tombstone and local has 'closed',
|
// tombstones. For example, if remote has a tombstone and local has 'closed',
|
||||||
@@ -808,26 +807,6 @@ func contentMergeRecovery(ctx context.Context, worktreePath, branch, remote stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetchAndRebaseInWorktree is DEPRECATED - kept for reference only.
|
|
||||||
// Use contentMergeRecovery instead to avoid tombstone resurrection.
|
|
||||||
func fetchAndRebaseInWorktree(ctx context.Context, worktreePath, branch, remote string) error {
|
|
||||||
// Fetch latest from remote
|
|
||||||
fetchCmd := exec.CommandContext(ctx, "git", "-C", worktreePath, "fetch", remote, branch)
|
|
||||||
if output, err := fetchCmd.CombinedOutput(); err != nil {
|
|
||||||
return fmt.Errorf("fetch failed: %w\n%s", err, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rebase local commits on top of remote
|
|
||||||
rebaseCmd := exec.CommandContext(ctx, "git", "-C", worktreePath, "rebase", fmt.Sprintf("%s/%s", remote, branch))
|
|
||||||
if output, err := rebaseCmd.CombinedOutput(); err != nil {
|
|
||||||
// Abort the failed rebase to leave worktree in clean state
|
|
||||||
abortCmd := exec.CommandContext(ctx, "git", "-C", worktreePath, "rebase", "--abort")
|
|
||||||
_ = abortCmd.Run() // Best effort
|
|
||||||
return fmt.Errorf("rebase failed: %w\n%s", err, output)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// runCmdWithTimeoutMessage runs a command and prints a helpful message if it takes too long.
|
// runCmdWithTimeoutMessage runs a command and prints a helpful message if it takes too long.
|
||||||
// This helps when git operations hang waiting for credential/browser auth.
|
// This helps when git operations hang waiting for credential/browser auth.
|
||||||
|
|||||||
@@ -349,38 +349,6 @@ func TestPreemptiveFetchAndFastForward(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFetchAndRebaseInWorktree tests the fetch and rebase function
|
|
||||||
func TestFetchAndRebaseInWorktree(t *testing.T) {
|
|
||||||
if testing.Short() {
|
|
||||||
t.Skip("skipping integration test in short mode")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
t.Run("returns error when fetch fails", func(t *testing.T) {
|
|
||||||
repoDir := setupTestRepoWithRemote(t)
|
|
||||||
defer os.RemoveAll(repoDir)
|
|
||||||
|
|
||||||
syncBranch := "beads-sync"
|
|
||||||
|
|
||||||
// Create sync branch locally
|
|
||||||
runGit(t, repoDir, "checkout", "-b", syncBranch)
|
|
||||||
writeFile(t, filepath.Join(repoDir, ".beads", "issues.jsonl"), `{"id":"test-1"}`)
|
|
||||||
runGit(t, repoDir, "add", ".")
|
|
||||||
runGit(t, repoDir, "commit", "-m", "initial")
|
|
||||||
|
|
||||||
// fetchAndRebaseInWorktree should fail since remote doesn't have the branch
|
|
||||||
err := fetchAndRebaseInWorktree(ctx, repoDir, syncBranch, "origin")
|
|
||||||
if err == nil {
|
|
||||||
// If it succeeds, it means the test setup allowed it (self remote)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Expected to fail
|
|
||||||
if !strings.Contains(err.Error(), "fetch failed") {
|
|
||||||
// Some other error - still acceptable
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper: setup a test repo with a (fake) remote
|
// Helper: setup a test repo with a (fake) remote
|
||||||
func setupTestRepoWithRemote(t *testing.T) string {
|
func setupTestRepoWithRemote(t *testing.T) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user