Adds issueops.Lifecycle — Create, Update, Close, Reopen — reached from the storage handle via store.IssueLifecycle(), implemented once and shared by the CLI and linked library consumers. Three backends implement it and a shared conformance suite asserts them against one spec. The bd CLI's create, update, close and reopen now route through it. Fixes several defects that predate this change and became visible once the write paths were forced to agree: swallowed metadata-edit failures, a claim applied before field validation, missing value validation on title/priority/estimate, silently dropped create edges to missing targets, infra-typed creates landing in the wrong table, a dropped SourceRepo, closed_by_session written but never read, and a compound update writing twice. Behavior changes needing release notes: create with an occupied explicit id now fails instead of silently overwriting; a compound update is one atomic operation with one hook and one version commit; reparenting replaces all parent edges; reopening something not closed reports nothing to do.
26 lines
1.1 KiB
Go
26 lines
1.1 KiB
Go
package issueops
|
|
|
|
import "context"
|
|
|
|
// deferVersionCommitKey marks a context whose guarded issue operations must
|
|
// leave their writes in the Dolt working set instead of creating a version
|
|
// commit.
|
|
type deferVersionCommitKey struct{}
|
|
|
|
// WithDeferredVersionCommit returns a context whose guarded issue operations
|
|
// skip the Dolt version commit they would otherwise create. The SQL write still
|
|
// commits; only the version commit is deferred to a later explicit commit point.
|
|
//
|
|
// `bd --dolt-auto-commit batch` needs this: batch mode exists to avoid one
|
|
// version commit per issue, and the commit point for the write verbs lives
|
|
// inside the storage layer, so the CLI has no commit message to blank the way
|
|
// it does on the RunInTransaction path.
|
|
func WithDeferredVersionCommit(ctx context.Context) context.Context {
|
|
return context.WithValue(ctx, deferVersionCommitKey{}, true)
|
|
}
|
|
|
|
// VersionCommitDeferred reports whether ctx defers version commits.
|
|
func VersionCommitDeferred(ctx context.Context) bool {
|
|
deferred, _ := ctx.Value(deferVersionCommitKey{}).(bool)
|
|
return deferred
|
|
}
|