(results []SourceResult, cfg config.Config)
| 183 | } |
| 184 | |
| 185 | func writeLock(results []SourceResult, cfg config.Config) error { |
| 186 | f, err := os.Create("sources_lock.yml") |
| 187 | if err != nil { |
| 188 | return fmt.Errorf("create lock file: %w", err) |
| 189 | } |
| 190 | defer f.Close() |
| 191 | |
| 192 | _, _ = fmt.Fprintf(f, "lock_date: %q\n", time.Now().UTC().Format(time.RFC3339)) |
| 193 | _, _ = fmt.Fprintln(f, "sources:") |
| 194 | for _, r := range results { |
| 195 | _, _ = fmt.Fprintf(f, " %s:\n", r.Name) |
| 196 | _, _ = fmt.Fprintf(f, " repo: %q\n", sourceRepo(cfg, r.Name)) |
| 197 | _, _ = fmt.Fprintf(f, " commit: %q\n", r.Commit) |
| 198 | _, _ = fmt.Fprintf(f, " downloaded_files: %d\n", r.DownloadedFiles) |
| 199 | _, _ = fmt.Fprintf(f, " last_updated: %q\n", time.Now().UTC().Format(time.RFC3339)) |
| 200 | } |
| 201 | return nil |
| 202 | } |
| 203 | |
| 204 | func sourceRepo(cfg config.Config, name string) string { |
| 205 | for _, s := range cfg.Sources { |
no test coverage detected