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

Function importTask

apps/cli/internal/sync/import_engine.go:106–135  ·  view source on GitHub ↗
(
	ext ExternalTask, cfg ImportConfig, fieldMap FieldMap,
	existingIDs []string, externalIDs map[string]bool,
)

Source from the content-addressed store, hash-verified

104}
105
106func 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).
138func defaultImportFieldMap() FieldMap {

Callers 1

RunImportFunction · 0.85

Calls 3

MapExternalTaskFunction · 0.85
appendSourceURLFunction · 0.85
WriteTaskFileFunction · 0.85

Tested by

no test coverage detected