deriveFieldsFromFilename extracts ID and title from a filename. Supports these patterns: 1. Sequential: "009-add-feature.md" → ID="009" 2. Prefixed: "dr-001-fix-login.md" → ID="dr-001" 3. Random: "a3f9x2-slug-title.md" → ID="a3f9x2" 4. UUID: "f47ac10b-fix-bug.md" → ID="f47ac10b" 5. Full
(task *model.Task)
| 104 | // 4. UUID: "f47ac10b-fix-bug.md" → ID="f47ac10b" |
| 105 | // 5. Full UUID: "f47ac10b-58cc-4372-a567-0e02b2c3d479-slug.md" → ID="f47ac10b-58cc-4372-a567-0e02b2c3d479" |
| 106 | func deriveFieldsFromFilename(task *model.Task) { |
| 107 | base := filepath.Base(task.FilePath) |
| 108 | name := strings.TrimSuffix(base, filepath.Ext(base)) |
| 109 | |
| 110 | if len(name) == 0 { |
| 111 | return |
| 112 | } |
| 113 | |
| 114 | id, slug := splitFilenameID(name) |
| 115 | if id == "" { |
| 116 | return |
| 117 | } |
| 118 | |
| 119 | if task.ID == "" { |
| 120 | task.ID = id |
| 121 | } |
| 122 | if task.Title == "" && slug != "" { |
| 123 | task.Title = strings.ReplaceAll(slug, "-", " ") |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | // splitFilenameID identifies the ID portion and remaining slug from a filename stem. |
| 128 | // Returns ("", "") if no ID pattern matches. |
no test coverage detected