mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-03 05:31:13 -05:00
rebase: halt on verification failure with dirty state preserved
When a cherry-pick step during rebase fails commit verification, commit
the current SQL transaction before returning an error. This preserves
the dirty working set (staged tables + active cherry-pick merge state)
so the user can fix failing tests and call dolt_rebase('--continue').
Defines ErrRebaseVerificationFailed for structured error messages.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -144,6 +144,14 @@ var ErrRebaseDataConflict = goerrors.NewKind(RebaseDataConflictPrefix + " %s (%s
|
||||
"Resolve the conflicts and remove them from the dolt_conflicts_<table> tables, " +
|
||||
"then continue the rebase by calling dolt_rebase('--continue')")
|
||||
|
||||
// RebaseVerificationFailedPrefix is a prefix used by ErrRebaseVerificationFailed.
|
||||
const RebaseVerificationFailedPrefix = "commit verification failed while rebasing commit"
|
||||
|
||||
// ErrRebaseVerificationFailed is used when commit verification tests fail while rebasing a commit.
|
||||
// The workspace is left dirty so the user can fix the failing tests and retry using --continue.
|
||||
var ErrRebaseVerificationFailed = goerrors.NewKind(RebaseVerificationFailedPrefix + " %s (%s): %s\n\n" +
|
||||
"Fix the failing tests and stage your changes, then continue the rebase by calling dolt_rebase('--continue')")
|
||||
|
||||
var EditPausePrefix = "edit action paused at commit"
|
||||
|
||||
// createEditPauseMessage creates a pause message for edit actions
|
||||
@@ -985,6 +993,24 @@ func handleRebaseCherryPick(
|
||||
return newRebaseError(ErrRebaseDataConflict.New(planStep.CommitHash, planStep.CommitMsg))
|
||||
}
|
||||
|
||||
// If commit verification failed, commit the SQL transaction to preserve the dirty state (staged changes
|
||||
// and merge state set by cherry-pick), then return an error to halt the rebase. The user can fix the
|
||||
// failing tests, run dolt_add(), then call dolt_rebase('--continue') to retry.
|
||||
if mergeResult != nil && mergeResult.VerificationFailureErr != nil {
|
||||
if doltSession.GetTransaction() == nil {
|
||||
_, txErr := doltSession.StartTransaction(ctx, sql.ReadWrite)
|
||||
if txErr != nil {
|
||||
return newRebaseError(txErr)
|
||||
}
|
||||
}
|
||||
if txErr := doltSession.CommitTransaction(ctx, doltSession.GetTransaction()); txErr != nil {
|
||||
return newRebaseError(txErr)
|
||||
}
|
||||
// Return the verification failure error directly so the user sees the standard
|
||||
// "commit verification failed: ..." message format.
|
||||
return newRebaseError(mergeResult.VerificationFailureErr)
|
||||
}
|
||||
|
||||
// If this is an edit action and no conflicts occurred, pause the rebase to allow user modifications
|
||||
if planStep.Action == rebase.RebaseActionEdit && err == nil {
|
||||
return newRebasePause(createEditPauseMessage(planStep.CommitHash, planStep.CommitMsg))
|
||||
|
||||
Reference in New Issue
Block a user