(node *yaml.Node)
| 209 | } |
| 210 | |
| 211 | func (t *Tasks) UnmarshalYAML(node *yaml.Node) error { |
| 212 | if t == nil || t.om == nil { |
| 213 | *t = *NewTasks() |
| 214 | } |
| 215 | switch node.Kind { |
| 216 | case yaml.MappingNode: |
| 217 | // NOTE: orderedmap does not have an unmarshaler, so we have to decode |
| 218 | // the map manually. We increment over 2 values at a time and assign |
| 219 | // them as a key-value pair. |
| 220 | for i := 0; i < len(node.Content); i += 2 { |
| 221 | keyNode := node.Content[i] |
| 222 | valueNode := node.Content[i+1] |
| 223 | |
| 224 | // Decode the value node into a Task struct |
| 225 | var v Task |
| 226 | if err := valueNode.Decode(&v); err != nil { |
| 227 | return errors.NewTaskfileDecodeError(err, node) |
| 228 | } |
| 229 | |
| 230 | // Set the task name and location |
| 231 | v.Task = keyNode.Value |
| 232 | v.Location = &Location{ |
| 233 | Line: keyNode.Line, |
| 234 | Column: keyNode.Column, |
| 235 | } |
| 236 | |
| 237 | // Add the task to the ordered map |
| 238 | t.Set(keyNode.Value, &v) |
| 239 | } |
| 240 | return nil |
| 241 | } |
| 242 | |
| 243 | return errors.NewTaskfileDecodeError(nil, node).WithTypeMessage("tasks") |
| 244 | } |
| 245 | |
| 246 | func taskNameWithNamespace(taskName string, namespace string) string { |
| 247 | if after, ok := strings.CutPrefix(taskName, NamespaceSeparator); ok { |
nothing calls this directly
no test coverage detected