MCPcopy Create free account
hub / github.com/driangle/taskmd / runCommitMsg

Function runCommitMsg

apps/cli/internal/cli/commit_msg.go:65–102  ·  view source on GitHub ↗
(_ *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

63}
64
65func runCommitMsg(_ *cobra.Command, _ []string) error {
66 if !allowedTypes[commitMsgType] {
67 return fmt.Errorf("invalid commit type %q (allowed: feat, fix, chore, docs, test, refactor)", commitMsgType)
68 }
69
70 flags := GetGlobalFlags()
71 scanDir := ResolveScanDir(nil)
72
73 taskScanner := scanner.NewScanner(scanDir, flags.Verbose, flags.IgnoreDirs)
74 result, err := taskScanner.Scan()
75 if err != nil {
76 return fmt.Errorf("scan failed: %w", err)
77 }
78
79 tasks := result.Tasks
80
81 warnDuplicateIDs(tasks)
82
83 if commitMsgTaskID != "" {
84 task := findExactMatch(commitMsgTaskID, tasks)
85 if task == nil {
86 return fmt.Errorf("task not found: %s", commitMsgTaskID)
87 }
88 fmt.Print(buildCommitMessage([]*model.Task{task}, commitMsgType, commitMsgBody, commitMsgShort))
89 return nil
90 }
91
92 changes, err := findTaskChangesFromDiff(tasks, scanDir)
93 if err != nil {
94 return err
95 }
96 if changes.IsEmpty() {
97 return fmt.Errorf("no task changes found in staged changes")
98 }
99
100 fmt.Print(buildMessageFromChanges(changes, commitMsgType, commitMsgBody, commitMsgShort))
101 return nil
102}
103
104// buildMessageFromChanges routes to the appropriate message builder based on
105// which change categories are present. Single-category changes use dedicated

Callers 1

captureCommitMsgOutputFunction · 0.85

Calls 9

ScanMethod · 0.95
GetGlobalFlagsFunction · 0.85
ResolveScanDirFunction · 0.85
warnDuplicateIDsFunction · 0.85
findExactMatchFunction · 0.85
buildCommitMessageFunction · 0.85
findTaskChangesFromDiffFunction · 0.85
buildMessageFromChangesFunction · 0.85
IsEmptyMethod · 0.45

Tested by 1

captureCommitMsgOutputFunction · 0.68