diff --git a/cmd/bd/delete.go b/cmd/bd/delete.go index 5d4b6e598..562fef3cc 100644 --- a/cmd/bd/delete.go +++ b/cmd/bd/delete.go @@ -153,6 +153,25 @@ Force: Delete and orphan dependents commandDidWrite.Store(true) + // THE DELETE IS VERSIONED HERE. issueops.Deleter reaches its transaction + // through withConn, which does a SQL commit and no Dolt version commit, so + // nothing below the role advances HEAD. Before the role this route ran + // transactHonoringAutoCommit with a "bd: delete " message, and that is + // what versioned the change; dropping it made embedded deletes unversioned + // and left a routed sibling's HEAD standing still. + // + // It commits the store the rows were actually deleted from, which for a + // prefix-routed id is the TARGET repository rather than this workspace. + // Batch and off modes are honored inside: maybeAutoCommitStore returns + // early unless auto-commit is on. + if err := commitPendingIfEmbedded(ctx, activeStore, actor, doltAutoCommitParams{ + Command: "delete", + IssueIDs: []string{issueID}, + MessageOverride: fmt.Sprintf("bd: delete %s", issueID), + }); err != nil { + WarnError("failed to commit: %v", err) + } + if jsonOutput { // The single-issue keys, unchanged: `deleted` is the id rather than a // list here, which is what every `bd delete --json` parses. @@ -345,6 +364,24 @@ func deleteBatch(_ *cobra.Command, issueIDs []string, force bool, dryRun bool, c commandDidWrite.Store(true) + // THE DELETE IS VERSIONED HERE. issueops.Deleter reaches its transaction + // through withConn, which does a SQL commit and no Dolt version commit, so + // nothing below the role advances HEAD. Before the role this route ran + // transactHonoringAutoCommit with a "bd: delete " message, and that is + // what versioned the change; dropping it made embedded deletes unversioned + // and left a routed sibling's HEAD standing still. + // + // It commits the store the rows were actually deleted from, which for a + // prefix-routed id is the TARGET repository rather than this workspace. + // Batch and off modes are honored inside: maybeAutoCommitStore returns + // early unless auto-commit is on. + if err := commitPendingIfEmbedded(ctx, batchStore, actor, doltAutoCommitParams{ + Command: "delete", + IssueIDs: resolvedIDs, + }); err != nil { + WarnError("failed to commit: %v", err) + } + if jsonOutput { if err := outputJSON(map[string]interface{}{ "deleted": resolvedIDs, diff --git a/cmd/bd/delete_proxied_server_output_test.go b/cmd/bd/delete_proxied_server_output_test.go index a4b4d3914..b9cf6683e 100644 --- a/cmd/bd/delete_proxied_server_output_test.go +++ b/cmd/bd/delete_proxied_server_output_test.go @@ -178,7 +178,9 @@ func TestOutputDeleteProxiedPreviewExactContracts(t *testing.T) { } func TestRenderDeleteProxiedResultExactContracts(t *testing.T) { - res := issueops.DeleteResult{Deleted: 3, Dependencies: 4, Labels: 2, Events: 5, ReferencesUpdated: 1, Orphaned: []string{"bd-orphan"}} + // No orphans on the base result: the subtests below assert the WITHOUT-orphans + // contract, and the orphan case copies this and adds its own. + res := issueops.DeleteResult{Deleted: 3, Dependencies: 4, Labels: 2, Events: 5, ReferencesUpdated: 1} t.Run("JSON includes the complete final aggregate", func(t *testing.T) { in := &deleteInput{ids: []string{"bd-target", "bd-dependent"}, jsonOutput: true} @@ -213,7 +215,6 @@ func TestRenderDeleteProxiedResultExactContracts(t *testing.T) { for _, required := range []string{ "Deleted 3 issue(s)", "Removed 4 dependency link(s)", "Removed 2 label(s)", "Removed 5 event(s)", "Updated text references in 1 issue(s)", - "Orphaned 1 issue(s): bd-orphan", } { if !strings.Contains(out, required) { t.Errorf("final prose missing %q:\n%s", required, out) diff --git a/cmd/bd/serve_proxied_integration_test.go b/cmd/bd/serve_proxied_integration_test.go index b21dcb4b8..098db92bf 100644 --- a/cmd/bd/serve_proxied_integration_test.go +++ b/cmd/bd/serve_proxied_integration_test.go @@ -221,14 +221,21 @@ func TestProxiedServerServeLifecycle(t *testing.T) { } // The handshake advertises exactly what this build implements. A client // that gates on capabilities is then correct without knowing which - // release it hit. With the read endpoints landed that is the whole v0 - // vocabulary; the assertion is on the derived list, not on a count, so - // the next operation to arrive stubbed still fails here. + // release it hit. The assertion is on the derived list, not on a count, + // so the next operation to arrive stubbed still fails here — which is + // what it did when the facade programme took this from four operations + // to sixteen. Update it deliberately when you add one. caps, ok := body["capabilities"].([]any) if !ok { t.Fatalf("capabilities = %#v, want an array", body["capabilities"]) } - want := []any{"issues.claim", "issues.get", "issues.list", "ready.list"} + want := []any{ + "config.get", "config.list", + "dependencies.blocking", "dependencies.cycles", "dependencies.list", "dependencies.tree", + "issues.batchCreate", "issues.claim", "issues.delete", "issues.get", "issues.list", + "issues.query", "issues.sweep", + "ready.count", "ready.list", "stats.get", + } if !reflect.DeepEqual(caps, want) { t.Errorf("capabilities = %v, want %v", caps, want) }