* feat: move hook firing into storage layer via decorator Add HookFiringStore decorator that wraps DoltStorage and automatically fires on_create/on_update/on_close hooks after successful mutations. This replaces manual hookRunner.Run() calls scattered across 8+ CLI command files, ensuring ALL mutations fire hooks — including future commands that haven't been written yet. Key features: - Decorator pattern: storage layer stays clean (no hooks dependency) - Transaction support: hookTrackingTransaction accumulates pending hooks during RunInTransaction, fires them only after successful commit. Rollback = no hooks. - Covers all mutation methods: CreateIssue(s), UpdateIssue, CloseIssue, ReopenIssue, UpdateIssueType, Add/RemoveDependency, Add/RemoveLabel, AddIssueComment - DeleteIssue intentionally skipped (destructive, no issue to pass) - Nil runner safe (passthrough only, no panics) Removed hookRunner.Run() from: create.go, update.go, close.go, note.go, assign.go, tag.go, priority.go. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add BD_NO_HOOKS env var to disable all hook firing Allows opting out of the HookFiringStore decorator entirely via BD_NO_HOOKS=1. Useful for bulk imports, migrations, or environments where eventing should not run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
99 lines
2.3 KiB
Go
99 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/beads/internal/ui"
|
|
"github.com/steveyegge/beads/internal/validation"
|
|
)
|
|
|
|
var priorityCmd = &cobra.Command{
|
|
Use: "priority <id> <n>",
|
|
GroupID: "issues",
|
|
Short: "Set the priority of an issue",
|
|
Long: `Set the priority of an issue.
|
|
|
|
Shorthand for 'bd update <id> --priority <n>'.
|
|
|
|
Priority levels:
|
|
0 - Critical (security, data loss, broken builds)
|
|
1 - High (major features, important bugs)
|
|
2 - Medium (default)
|
|
3 - Low (polish, optimization)
|
|
4 - Backlog (future ideas)
|
|
|
|
Examples:
|
|
bd priority bd-123 0 # Critical
|
|
bd priority bd-123 2 # Medium`,
|
|
Args: cobra.ExactArgs(2),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
CheckReadonly("priority")
|
|
|
|
id := args[0]
|
|
priorityStr := args[1]
|
|
|
|
priority, err := validation.ValidatePriority(priorityStr)
|
|
if err != nil {
|
|
FatalErrorRespectJSON("%v", err)
|
|
}
|
|
|
|
ctx := rootCtx
|
|
|
|
result, err := resolveAndGetIssueWithRouting(ctx, store, id)
|
|
if err != nil {
|
|
if result != nil {
|
|
result.Close()
|
|
}
|
|
FatalErrorRespectJSON("resolving %s: %v", id, err)
|
|
}
|
|
if result == nil || result.Issue == nil {
|
|
if result != nil {
|
|
result.Close()
|
|
}
|
|
FatalErrorRespectJSON("issue %s not found", id)
|
|
}
|
|
defer result.Close()
|
|
|
|
issueStore := result.Store
|
|
|
|
if err := validateIssueUpdatable(id, result.Issue); err != nil {
|
|
FatalErrorRespectJSON("%s", err)
|
|
}
|
|
|
|
updates := map[string]interface{}{
|
|
"priority": priority,
|
|
}
|
|
if err := issueStore.UpdateIssue(ctx, result.ResolvedID, updates, actor); err != nil {
|
|
FatalErrorRespectJSON("updating %s: %v", id, err)
|
|
}
|
|
|
|
// Flush Dolt commit for embedded mode
|
|
if isEmbeddedMode() && store != nil {
|
|
if _, err := store.CommitPending(ctx, actor); err != nil {
|
|
FatalErrorRespectJSON("failed to commit: %v", err)
|
|
}
|
|
}
|
|
|
|
SetLastTouchedID(result.ResolvedID)
|
|
|
|
// Re-fetch for display
|
|
updatedIssue, _ := issueStore.GetIssue(ctx, result.ResolvedID)
|
|
title := ""
|
|
if updatedIssue != nil {
|
|
title = updatedIssue.Title
|
|
}
|
|
if jsonOutput {
|
|
if updatedIssue != nil {
|
|
outputJSON(updatedIssue)
|
|
}
|
|
} else {
|
|
fmt.Printf("%s Set priority of %s to P%d\n", ui.RenderPass("✓"), formatFeedbackID(result.ResolvedID, title), priority)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
priorityCmd.ValidArgsFunction = issueIDCompletion
|
|
rootCmd.AddCommand(priorityCmd)
|
|
}
|