* feat(unclaim): port --if-assignee to proxied-server mode (bd-tb0yi)
`bd unclaim --if-assignee` was refused outright under
BEADS_DOLT_PROXIED_SERVER ("not supported in proxied-server mode"); it now
runs the compare-and-swap release, and runs the SAME one the embedded
backend runs.
No new SQL is written for this port, and that is what holds the bar. The
conditional release reaches the classic implementation exactly as the
unconditional one already does: domain.IssueUseCase.UnclaimIfAssignee ->
IssueSQLRepository.UnclaimIssueIfAssignee ->
issueops.UnclaimIssueIfAssigneeInTx, the twin of the Unclaim ->
UnclaimIssue -> UnclaimIssueInTx chain beside it. So a conditional release
applies the same transition (assignee cleared, status reopened, started_at
cleared, lease row dropped, row_lock rewritten), records the same
"unclaimed" event, routes a wisp's claim to the wisp tables the same way,
and refuses with the same storage.ErrAssigneeMismatch naming the current
holder. Routing it instead through Lifecycle.Update + ExpectedAssignee
would have written the row correctly but recorded a generic update event
in place of the release, and diverged from the unconditional path inside
the same command.
The CLI passes the expectation as a plain string because the flag has only
two states here: `--if-assignee ""` is rejected in unclaim.go before any
issue is touched (an unset shell variable must never silently downgrade a
CAS to an unconditional release), so empty unambiguously means
unconditional.
EXIT CONTRACT, unchanged and deliberately not "improved": a mismatched
holder writes nothing and exits 1 on BOTH paths. `bd unclaim` has never had
`bd update`'s ExitGuardMismatch (13) verdict — its help says so outright
("1 when any release failed (including an --if-assignee mismatch)") — and
minting one on the proxied path only would be the exact divergence this
lane exists to prevent. If unclaim should adopt 13, it adopts it in both
modes, as its own change.
TestProxiedServerUnclaimIfAssigneeParity is the cross-mode oracle: six
steps (stale guard, matching guard, repeat release, `--if-assignee ""`
rejection, --force/--if-assignee rejection) run against an embedded
workspace and a proxied one, and every observable — exit code, post-step
row state, whether the refusal names the holder — must match, with each
mode also checked against the contract itself so parity with a shared bug
still fails. It rides a new cross-mode harness
(cross_mode_parity_harness_test.go): one initialized workspace per backend,
the same argv against both, outcomes compared field by field and never by
id.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014zUQg5iF119KbGeYuhXQ5Y
* feat(batch): port bd batch to proxied-server mode (bd-tb0yi)
`bd batch` was refused outright under BEADS_DOLT_PROXIED_SERVER; it now
runs, with the property that is its entire reason to exist intact: N
operations, ONE transaction, ONE commit, and whole-batch rollback on the
first failing line.
The split between the modes is exactly the command's own seam. The
grammar, the tokenizer, the arity checks, the dry-run echo, the
empty-input no-op, the default commit message and every byte of output
stay shared in batch.go — a batch script means the same thing whichever
backend runs it, and a script the parser rejects is rejected before either
backend is reached. What is per-mode is the transaction primitive and the
verbs the ops dispatch against: uow.RunTxResult + the unit of work's use
cases here, `transact` + storage.Transaction there. runBatchOpUOW mirrors
runBatchOp op for op, including its error strings.
RunTxResult, not RunTxEphemeral: a batch writes versioned tables, and the
ephemeral form commits with no Dolt commit (its whole point for the leases
table), which would persist these writes while bypassing Dolt history. The
retry it brings redoes the WHOLE batch in a fresh unit of work on a
serialization failure — re-executed against the winner's committed rows,
never re-committed on a session the server already rolled back — and the
per-attempt result slice means a retried batch reports the attempt that
actually committed.
Plane routing is explicit because it has to be: the classic transaction
methods route an id to the issues or wisps tables themselves, while the
domain exposes the planes as separate verbs. close/update resolve through
workapi.GetIssueOrWisp inside the transaction and call the matching verb;
dep add/remove use the source-routed AddDependencies /
RemoveDependencyBySource, which land each edge in the plane its own source
lives in. `close` is deliberately the UNCHECKED close, matching the classic
batch: `close <id>` in a batch applies no close policy, while an `update`
that crosses into done does — an asymmetry the command's help documents.
TestProxiedServerBatchParity is the cross-mode oracle, on the F0-style
harness: the same script runs against an embedded workspace and a proxied
one, and exit codes, the summary line, the per-line report, and the rows
left behind must match — including the two transactional cases that are
the point (a failing last line undoing the successful lines before it, and
a grammar error writing nothing at all).
TWO KNOWN DIVERGENCES are named at their sites and left for their own
change, because neither changes the rows a batch lands and both are
classic-batch inconsistencies with the CLI verbs rather than artifacts of
the port: an out-of-range `priority=5` is written by the classic batch and
refused by the proxied one (the domain update funnel validates the range,
issueops' transaction path does not; `bd update --priority 5` is refused on
both), and a batched `dep add`/`dep remove` records a dependency history
event here and not there (every domain edge verb emits, the classic batch's
bare transaction method does not — and `bd dep add` at the CLI emits on
both backends, which is what makes the classic batch the outlier).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014zUQg5iF119KbGeYuhXQ5Y
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
507 lines
15 KiB
Go
507 lines
15 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/beads/internal/metrics"
|
|
"github.com/steveyegge/beads/internal/storage"
|
|
"github.com/steveyegge/beads/internal/storage/issueops"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// Scope note:
|
|
// `bd batch` is intentionally a narrow, write-oriented command runner. It does
|
|
// NOT re-use the top-level cobra handlers (close/update/create/dep) because
|
|
// those handlers read the global `store` and perform a full connection-
|
|
// per-operation workflow. Instead, batch parses a simple line-oriented grammar
|
|
// and dispatches directly against a shared storage.Transaction so the entire
|
|
// batch executes as a single dolt transaction (one DOLT_COMMIT).
|
|
//
|
|
// The supported grammar is a documented subset that matches what a downstream
|
|
// consumer's shell-script "orders" (gate-sweep.sh, spawn-storm-detect.sh,
|
|
// cross-rig-deps.sh) actually call in loops. See the Long help below for the
|
|
// exact list. Unsupported commands error out loudly.
|
|
|
|
var batchCmd = &cobra.Command{
|
|
Use: "batch",
|
|
GroupID: "maint",
|
|
Short: "Run multiple write operations in a single database transaction",
|
|
Long: `Run multiple write operations in a single database transaction.
|
|
|
|
Commands are read from stdin (one per line) or from a file via -f/--file.
|
|
All operations execute inside a single dolt transaction: on any error the
|
|
whole batch is rolled back, otherwise it is committed with one DOLT_COMMIT.
|
|
|
|
This is intended for shell scripts that currently invoke 'bd' many times in
|
|
a loop, which causes severe write amplification on a dolt sql-server backed
|
|
by btrfs+compression. Batching collapses N invocations into one transaction
|
|
and one dolt commit.
|
|
|
|
Grammar (one command per line):
|
|
close <id> [reason...]
|
|
update <id> <key>=<value> [<key>=<value> ...]
|
|
create <type> <priority> <title...>
|
|
dep add <from-id> <to-id> [type]
|
|
dep remove <from-id> <to-id>
|
|
#comment (blank lines and '# ...' comments are ignored)
|
|
|
|
Supported 'update' keys: status, priority, title, assignee, force
|
|
Supported dependency types: see 'bd dep add --help' (default: blocks)
|
|
|
|
'force' is not a field. An update whose status moves the issue into closed
|
|
(or a configured done status) is refused when it still has open children or
|
|
a live blocker, the same as 'bd close'; 'force=true' overrides that refusal.
|
|
Because the batch is one transaction, an unforced refusal rolls back EVERY
|
|
operation in the batch, not just the offending line. Note the asymmetry with
|
|
'close <id>', which does not apply that policy at all.
|
|
|
|
Tokens are whitespace-separated. Double-quoted strings ("like this") may
|
|
contain spaces; use \" to embed a quote and \\ for a backslash.
|
|
|
|
Examples:
|
|
# From a pipe
|
|
bd list --status stale -q | awk '{print "close",$1," stale"}' | bd batch
|
|
|
|
# From a file
|
|
bd batch -f operations.txt
|
|
|
|
# Inline
|
|
printf 'close bd-1 done\nupdate bd-2 status=in_progress\n' | bd batch
|
|
|
|
On success, exits 0 and prints a summary (or JSON with --json). On any error,
|
|
rolls back the entire transaction and exits non-zero with the failing line.
|
|
|
|
NOTE: This is a narrow subset. Commands like 'show', 'list', 'ready', 'sync',
|
|
complex create flows, or any flag not listed above are NOT accepted. Use
|
|
normal 'bd' subcommands for interactive/read operations.`,
|
|
Args: cobra.NoArgs,
|
|
SilenceUsage: true,
|
|
SilenceErrors: false,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
CheckReadonly("batch")
|
|
|
|
evt := metrics.NewCommandEvent("batch")
|
|
defer func() {
|
|
if c := metrics.Global(); c != nil {
|
|
c.CloseEventAndAdd(evt)
|
|
}
|
|
}()
|
|
|
|
proxied := usesProxiedServer()
|
|
if !proxied && store == nil {
|
|
return fmt.Errorf("no database connection available (%s)", diagHint())
|
|
}
|
|
|
|
filePath, _ := cmd.Flags().GetString("file")
|
|
dryRun, _ := cmd.Flags().GetBool("dry-run")
|
|
commitMsg, _ := cmd.Flags().GetString("message")
|
|
|
|
var reader io.Reader
|
|
if filePath != "" {
|
|
f, err := os.Open(filePath) // #nosec G304 -- user-supplied batch file
|
|
if err != nil {
|
|
return fmt.Errorf("open batch file: %w", err)
|
|
}
|
|
defer f.Close()
|
|
reader = f
|
|
} else {
|
|
reader = cmd.InOrStdin()
|
|
}
|
|
|
|
ops, err := parseBatchScript(reader)
|
|
if err != nil {
|
|
return fmt.Errorf("parsing batch input: %w", err)
|
|
}
|
|
|
|
if dryRun {
|
|
// In dry-run mode, just echo what would run. This is helpful for
|
|
// shell script authors verifying their scripts before running.
|
|
for _, op := range ops {
|
|
fmt.Fprintf(cmd.OutOrStdout(), "line %d: %s\n", op.line, op.raw)
|
|
}
|
|
if jsonOutput {
|
|
if err := outputJSON(map[string]interface{}{
|
|
"dry_run": true,
|
|
"operations": len(ops),
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
fmt.Fprintf(cmd.OutOrStdout(), "%d operations parsed (dry-run, nothing executed)\n", len(ops))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
if len(ops) == 0 {
|
|
// Empty input is a no-op success, matching 'bd list | bd batch' on
|
|
// an empty list.
|
|
if jsonOutput {
|
|
if err := outputJSON(map[string]interface{}{
|
|
"operations": 0,
|
|
"status": "ok",
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
fmt.Fprintln(cmd.OutOrStdout(), "batch: 0 operations (no-op)")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
if strings.TrimSpace(commitMsg) == "" {
|
|
commitMsg = fmt.Sprintf("bd: batch %d ops by %s", len(ops), getActor())
|
|
}
|
|
|
|
ctx := rootCtx
|
|
if ctx == nil {
|
|
ctx = context.Background()
|
|
}
|
|
|
|
// One transaction, one commit message, whole-batch rollback on the first
|
|
// failing line — the contract is the same on both backends; only the
|
|
// transaction primitive differs (uow.RunTx there, transact here), and
|
|
// both wrap a per-op dispatch that shares this file's parser.
|
|
var results []batchOpResult
|
|
if proxied {
|
|
results, err = runBatchProxiedServer(ctx, ops, commitMsg)
|
|
} else {
|
|
results = make([]batchOpResult, 0, len(ops))
|
|
err = transact(ctx, store, commitMsg, func(tx storage.Transaction) error {
|
|
for _, op := range ops {
|
|
res, rerr := runBatchOp(ctx, tx, op)
|
|
if rerr != nil {
|
|
return fmt.Errorf("line %d (%s): %w", op.line, op.raw, rerr)
|
|
}
|
|
results = append(results, res)
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
if err != nil {
|
|
if jsonOutput {
|
|
if jerr := outputJSONError(err, "batch_error"); jerr != nil {
|
|
return errors.Join(err, jerr)
|
|
}
|
|
}
|
|
return err
|
|
}
|
|
|
|
commandDidWrite.Store(true)
|
|
|
|
if jsonOutput {
|
|
if err := outputJSON(map[string]interface{}{
|
|
"operations": len(results),
|
|
"status": "ok",
|
|
"results": results,
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
fmt.Fprintf(cmd.OutOrStdout(), "batch: %d operations committed\n", len(results))
|
|
for _, r := range results {
|
|
fmt.Fprintf(cmd.OutOrStdout(), " line %d: %s %s\n", r.Line, r.Op, r.Target)
|
|
}
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
batchCmd.Flags().StringP("file", "f", "", "Read commands from file instead of stdin")
|
|
batchCmd.Flags().Bool("dry-run", false, "Parse input and echo commands without executing")
|
|
batchCmd.Flags().StringP("message", "m", "", "DOLT_COMMIT message (default: 'bd: batch N ops by <actor>')")
|
|
rootCmd.AddCommand(batchCmd)
|
|
}
|
|
|
|
// batchOp is one parsed command line.
|
|
type batchOp struct {
|
|
line int // 1-based source line number
|
|
raw string // original source line (for error messages)
|
|
cmd string // canonical command name, e.g. "close", "update", "dep.add"
|
|
args []string // remaining tokens
|
|
}
|
|
|
|
// batchOpResult is emitted per executed op for JSON reporting.
|
|
type batchOpResult struct {
|
|
Line int `json:"line"`
|
|
Op string `json:"op"`
|
|
Target string `json:"target,omitempty"`
|
|
}
|
|
|
|
// parseBatchScript reads the whole input and tokenizes each non-empty,
|
|
// non-comment line. It rejects unknown commands immediately so a bad script
|
|
// fails before any writes.
|
|
func parseBatchScript(r io.Reader) ([]batchOp, error) {
|
|
scanner := bufio.NewScanner(r)
|
|
// Allow long lines (descriptions, multi-token updates).
|
|
scanner.Buffer(make([]byte, 64*1024), 4*1024*1024)
|
|
|
|
var ops []batchOp
|
|
lineNo := 0
|
|
for scanner.Scan() {
|
|
lineNo++
|
|
raw := scanner.Text()
|
|
trimmed := strings.TrimSpace(raw)
|
|
if trimmed == "" || strings.HasPrefix(trimmed, "#") {
|
|
continue
|
|
}
|
|
tokens, err := tokenizeBatchLine(trimmed)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("line %d: %w", lineNo, err)
|
|
}
|
|
if len(tokens) == 0 {
|
|
continue
|
|
}
|
|
op := batchOp{line: lineNo, raw: trimmed}
|
|
switch tokens[0] {
|
|
case "close":
|
|
op.cmd = "close"
|
|
op.args = tokens[1:]
|
|
case "update":
|
|
op.cmd = "update"
|
|
op.args = tokens[1:]
|
|
case "create":
|
|
op.cmd = "create"
|
|
op.args = tokens[1:]
|
|
case "dep":
|
|
if len(tokens) < 2 {
|
|
return nil, fmt.Errorf("line %d: 'dep' requires a subcommand (add|remove)", lineNo)
|
|
}
|
|
switch tokens[1] {
|
|
case "add":
|
|
op.cmd = "dep.add"
|
|
case "remove", "rm":
|
|
op.cmd = "dep.remove"
|
|
default:
|
|
return nil, fmt.Errorf("line %d: unknown dep subcommand %q (want add|remove)", lineNo, tokens[1])
|
|
}
|
|
op.args = tokens[2:]
|
|
default:
|
|
return nil, fmt.Errorf("line %d: unsupported batch command %q (supported: close, update, create, dep add, dep remove)", lineNo, tokens[0])
|
|
}
|
|
ops = append(ops, op)
|
|
}
|
|
if err := scanner.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return ops, nil
|
|
}
|
|
|
|
// tokenizeBatchLine splits a line into whitespace-separated tokens with
|
|
// support for double-quoted strings. Escape sequences inside quotes: \" and
|
|
// \\. Anything else after a backslash inside quotes is treated literally.
|
|
func tokenizeBatchLine(s string) ([]string, error) {
|
|
var tokens []string
|
|
var cur strings.Builder
|
|
inQuote := false
|
|
hasToken := false
|
|
for i := 0; i < len(s); i++ {
|
|
c := s[i]
|
|
if inQuote {
|
|
if c == '\\' && i+1 < len(s) {
|
|
next := s[i+1]
|
|
if next == '"' || next == '\\' {
|
|
cur.WriteByte(next)
|
|
i++
|
|
continue
|
|
}
|
|
cur.WriteByte(c)
|
|
continue
|
|
}
|
|
if c == '"' {
|
|
inQuote = false
|
|
continue
|
|
}
|
|
cur.WriteByte(c)
|
|
continue
|
|
}
|
|
if c == '"' {
|
|
inQuote = true
|
|
hasToken = true
|
|
continue
|
|
}
|
|
if c == ' ' || c == '\t' {
|
|
if hasToken {
|
|
tokens = append(tokens, cur.String())
|
|
cur.Reset()
|
|
hasToken = false
|
|
}
|
|
continue
|
|
}
|
|
hasToken = true
|
|
cur.WriteByte(c)
|
|
}
|
|
if inQuote {
|
|
return nil, fmt.Errorf("unterminated quoted string")
|
|
}
|
|
if hasToken {
|
|
tokens = append(tokens, cur.String())
|
|
}
|
|
return tokens, nil
|
|
}
|
|
|
|
// runBatchOp dispatches a single parsed op against the shared transaction.
|
|
// It intentionally does NOT call any of the non-tx cobra handlers; it talks
|
|
// straight to storage.Transaction so everything joins the same SQL tx.
|
|
func runBatchOp(ctx context.Context, tx storage.Transaction, op batchOp) (batchOpResult, error) {
|
|
actorName := getActor()
|
|
result := batchOpResult{Line: op.line, Op: op.cmd}
|
|
switch op.cmd {
|
|
case "close":
|
|
if len(op.args) < 1 {
|
|
return result, fmt.Errorf("close requires <id>")
|
|
}
|
|
id := op.args[0]
|
|
reason := "Closed"
|
|
if len(op.args) > 1 {
|
|
reason = strings.Join(op.args[1:], " ")
|
|
}
|
|
if err := tx.CloseIssue(ctx, id, reason, actorName, ""); err != nil {
|
|
return result, err
|
|
}
|
|
result.Target = id
|
|
return result, nil
|
|
|
|
case "update":
|
|
if len(op.args) < 2 {
|
|
return result, fmt.Errorf("update requires <id> and at least one key=value")
|
|
}
|
|
id := op.args[0]
|
|
updates, err := parseUpdateKVs(op.args[1:])
|
|
if err != nil {
|
|
return result, err
|
|
}
|
|
if err := tx.UpdateIssue(ctx, id, updates, actorName); err != nil {
|
|
return result, err
|
|
}
|
|
result.Target = id
|
|
return result, nil
|
|
|
|
case "create":
|
|
if len(op.args) < 3 {
|
|
return result, fmt.Errorf("create requires <type> <priority> <title>")
|
|
}
|
|
issueType := types.IssueType(op.args[0])
|
|
// Accept common custom types too; fall back to type validation by the
|
|
// storage layer which knows about configured custom types. We only
|
|
// reject obviously-empty input here.
|
|
if strings.TrimSpace(op.args[0]) == "" {
|
|
return result, fmt.Errorf("create: type cannot be empty")
|
|
}
|
|
priority, err := strconv.Atoi(op.args[1])
|
|
if err != nil {
|
|
return result, fmt.Errorf("create: invalid priority %q: %w", op.args[1], err)
|
|
}
|
|
title := strings.Join(op.args[2:], " ")
|
|
if strings.TrimSpace(title) == "" {
|
|
return result, fmt.Errorf("create: title cannot be empty")
|
|
}
|
|
issue := &types.Issue{
|
|
Title: title,
|
|
IssueType: issueType,
|
|
Status: types.StatusOpen,
|
|
Priority: priority,
|
|
}
|
|
if err := tx.CreateIssue(ctx, issue, actorName); err != nil {
|
|
return result, err
|
|
}
|
|
result.Target = issue.ID
|
|
return result, nil
|
|
|
|
case "dep.add":
|
|
if len(op.args) < 2 {
|
|
return result, fmt.Errorf("dep add requires <from-id> <to-id>")
|
|
}
|
|
from, to := op.args[0], op.args[1]
|
|
depType := "blocks"
|
|
if len(op.args) >= 3 {
|
|
depType = op.args[2]
|
|
}
|
|
dt := types.DependencyType(depType)
|
|
if !dt.IsValid() {
|
|
return result, fmt.Errorf("dep add: invalid dependency type %q", depType)
|
|
}
|
|
dep := &types.Dependency{
|
|
IssueID: from,
|
|
DependsOnID: to,
|
|
Type: dt,
|
|
}
|
|
if err := tx.AddDependency(ctx, dep, actorName); err != nil {
|
|
return result, err
|
|
}
|
|
result.Target = fmt.Sprintf("%s->%s", from, to)
|
|
return result, nil
|
|
|
|
case "dep.remove":
|
|
if len(op.args) < 2 {
|
|
return result, fmt.Errorf("dep remove requires <from-id> <to-id>")
|
|
}
|
|
from, to := op.args[0], op.args[1]
|
|
if err := tx.RemoveDependency(ctx, from, to, actorName); err != nil {
|
|
return result, err
|
|
}
|
|
result.Target = fmt.Sprintf("%s->%s", from, to)
|
|
return result, nil
|
|
}
|
|
return result, fmt.Errorf("internal: unhandled batch op %q", op.cmd)
|
|
}
|
|
|
|
// parseUpdateKVs walks a slice of "key=value" tokens and builds the updates
|
|
// map accepted by storage.Transaction.UpdateIssue. Only a small, documented
|
|
// subset of fields is allowed — anything else is a hard error so typos in
|
|
// scripts never silently drop updates.
|
|
func parseUpdateKVs(kvs []string) (map[string]interface{}, error) {
|
|
updates := make(map[string]interface{}, len(kvs))
|
|
for _, kv := range kvs {
|
|
eq := strings.IndexByte(kv, '=')
|
|
if eq <= 0 {
|
|
return nil, fmt.Errorf("update: expected key=value, got %q", kv)
|
|
}
|
|
key := strings.TrimSpace(kv[:eq])
|
|
value := kv[eq+1:]
|
|
switch key {
|
|
case "status":
|
|
if !types.Status(value).IsValid() {
|
|
// IsValid excludes custom statuses; the transaction layer will
|
|
// re-validate. Still reject blatantly empty values here.
|
|
if strings.TrimSpace(value) == "" {
|
|
return nil, fmt.Errorf("update: status cannot be empty")
|
|
}
|
|
}
|
|
updates["status"] = value
|
|
case "priority":
|
|
p, err := strconv.Atoi(value)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("update: invalid priority %q: %w", value, err)
|
|
}
|
|
updates["priority"] = p
|
|
case "title":
|
|
if strings.TrimSpace(value) == "" {
|
|
return nil, fmt.Errorf("update: title cannot be empty")
|
|
}
|
|
updates["title"] = value
|
|
case "assignee":
|
|
updates["assignee"] = value
|
|
case "force":
|
|
// Not a field: the override for close policy on a status that
|
|
// crosses into done, spelled as a token because a batch script has
|
|
// no flags. The write funnel pops it before validating fields.
|
|
force, err := strconv.ParseBool(value)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("update: invalid force %q: %w", value, err)
|
|
}
|
|
updates[issueops.OpForceClosePolicy] = force
|
|
default:
|
|
return nil, fmt.Errorf("update: unsupported key %q (allowed: status, priority, title, assignee, force)", key)
|
|
}
|
|
}
|
|
return updates, nil
|
|
}
|