( ext ExternalTask, cfg ImportConfig, fieldMap FieldMap, existingIDs []string, externalIDs map[string]bool, )
| 104 | } |
| 105 | |
| 106 | func importTask( |
| 107 | ext ExternalTask, cfg ImportConfig, fieldMap FieldMap, |
| 108 | existingIDs []string, externalIDs map[string]bool, |
| 109 | ) (importActionInternal, []string) { |
| 110 | if externalIDs[ext.ExternalID] { |
| 111 | return importActionInternal{ImportAction: ImportAction{ |
| 112 | ExternalID: ext.ExternalID, Title: ext.Title, Reason: "skipped_duplicate", |
| 113 | }}, existingIDs |
| 114 | } |
| 115 | |
| 116 | mapped := MapExternalTask(ext, fieldMap) |
| 117 | mapped.Description = appendSourceURL(mapped.Description, ext.URL) |
| 118 | |
| 119 | newID := nextid.Calculate(existingIDs).NextID |
| 120 | action := importActionInternal{ImportAction: ImportAction{ |
| 121 | ExternalID: ext.ExternalID, LocalID: newID, Title: ext.Title, Reason: "created", |
| 122 | }} |
| 123 | |
| 124 | if !cfg.DryRun { |
| 125 | filePath, err := WriteTaskFile(cfg.OutputDir, newID, mapped, ext.ExternalID, cfg.SourceName) |
| 126 | if err != nil { |
| 127 | action.Reason = "error" |
| 128 | action.err = err |
| 129 | return action, existingIDs |
| 130 | } |
| 131 | action.FilePath = filePath |
| 132 | } |
| 133 | |
| 134 | return action, append(existingIDs, newID) |
| 135 | } |
| 136 | |
| 137 | // defaultImportFieldMap returns sensible defaults for one-shot imports (GitHub-oriented). |
| 138 | func defaultImportFieldMap() FieldMap { |
no test coverage detected