scanExistingTasks scans the directory for task IDs and external_ids.
(dir string, verbose bool)
| 176 | |
| 177 | // scanExistingTasks scans the directory for task IDs and external_ids. |
| 178 | func scanExistingTasks(dir string, verbose bool) (ids []string, externalIDs map[string]bool, err error) { |
| 179 | externalIDs = make(map[string]bool) |
| 180 | |
| 181 | if _, statErr := os.Stat(dir); os.IsNotExist(statErr) { |
| 182 | return nil, externalIDs, nil |
| 183 | } |
| 184 | |
| 185 | taskScanner := scanner.NewScanner(dir, verbose, nil) |
| 186 | result, err := taskScanner.Scan() |
| 187 | if err != nil { |
| 188 | return nil, nil, err |
| 189 | } |
| 190 | |
| 191 | ids = make([]string, 0, len(result.Tasks)) |
| 192 | for _, t := range result.Tasks { |
| 193 | ids = append(ids, t.ID) |
| 194 | if t.ExternalID != "" { |
| 195 | externalIDs[t.ExternalID] = true |
| 196 | } |
| 197 | } |
| 198 | return ids, externalIDs, nil |
| 199 | } |
| 200 | |
| 201 | // appendSourceURL appends a source reference to the task description. |
| 202 | func appendSourceURL(description, url string) string { |