Remove pre-emptive RunCommitVerification from merge, make helpers private

The pre-emptive verification call before NewPendingCommit in executeNoFFMerge
duplicated the verification that already runs inside GetCommitStaged. Remove it
and let NewPendingCommit surface ErrCommitVerificationFailed, handling it the
same way the caller already did.

Since RunCommitVerification and GetCommitRunTestGroups are now only called within
the actions package, make them unexported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Neil Macneale IV
2026-02-27 02:01:58 +00:00
parent 5c51504314
commit 66470662f6
2 changed files with 10 additions and 20 deletions

View File

@@ -55,10 +55,10 @@ const (
DoltCommitVerificationGroups = "dolt_commit_verification_groups"
)
// GetCommitRunTestGroups returns the test groups to run for commit operations
// getCommitRunTestGroups returns the test groups to run for commit operations
// Returns empty slice if no tests should be run, ["*"] if all tests should be run,
// or specific group names if only those groups should be run
func GetCommitRunTestGroups() []string {
func getCommitRunTestGroups() []string {
_, val, ok := sql.SystemVariables.GetGlobal(DoltCommitVerificationGroups)
if !ok {
return nil
@@ -157,9 +157,9 @@ func GetCommitStaged(
}
if !props.SkipVerification {
testGroups := GetCommitRunTestGroups()
testGroups := getCommitRunTestGroups()
if len(testGroups) > 0 {
err := RunCommitVerification(ctx, testGroups)
err := runCommitVerification(ctx, testGroups)
if err != nil {
return nil, err
}
@@ -174,10 +174,10 @@ func GetCommitStaged(
return db.NewPendingCommit(ctx, roots, mergeParents, props.Amend, meta)
}
// RunCommitVerification runs the commit verification tests for the given test groups.
// runCommitVerification runs the commit verification tests for the given test groups.
// If any tests fail, it returns ErrCommitVerificationFailed wrapping the failure details.
// Callers can use errors.Is(err, ErrCommitVerificationFailed) to detect this case.
func RunCommitVerification(ctx *sql.Context, testGroups []string) error {
func runCommitVerification(ctx *sql.Context, testGroups []string) error {
type sessionInterface interface {
sql.Session
GenericProvider() sql.MutableDatabaseProvider

View File

@@ -458,28 +458,18 @@ func executeNoFFMerge(
return ws.WithStagedRoot(roots.Staged), nil, nil
}
// Run commit verification before creating the pending commit. On failure we return the ws (which already
// has the dirty merge state set in the session) along with the verification error. The caller
// (performMerge) converts this to a non-error result row so the SQL transaction commits normally and
// preserves the dirty merge state for the user to fix and retry with CALL dolt_commit().
if !skipVerification {
testGroups := actions.GetCommitRunTestGroups()
if len(testGroups) > 0 {
if verifyErr := actions.RunCommitVerification(ctx, testGroups); verifyErr != nil {
return ws, nil, verifyErr
}
}
}
pendingCommit, err := dSess.NewPendingCommit(ctx, dbName, roots, actions.CommitStagedProps{
Message: msg,
Date: spec.Date,
Force: spec.Force,
Name: spec.Name,
Email: spec.Email,
SkipVerification: true, // Verification already ran above (or was skipped via skipVerification flag)
SkipVerification: skipVerification,
})
if err != nil {
if actions.ErrCommitVerificationFailed.Is(err) {
return ws, nil, err
}
return nil, nil, err
}