| 15 | ) |
| 16 | |
| 17 | func (c client) GetFiles( |
| 18 | ctx context.Context, |
| 19 | owner string, |
| 20 | repoName string, |
| 21 | commit string, |
| 22 | repo filter.Repo, |
| 23 | ) ([]content.File, error) { |
| 24 | reqID := connectpkg.RequestIDFrom(ctx) |
| 25 | |
| 26 | start := time.Now() |
| 27 | c.log.DebugContext(ctx, "github GetFiles start", |
| 28 | slog.String("owner", owner), |
| 29 | slog.String("repo", repoName), |
| 30 | slog.String("commit", commit), |
| 31 | slog.String("request_id", reqID), |
| 32 | ) |
| 33 | tree, _, err := c.git.GetTree(ctx, owner, repoName, commit, true) |
| 34 | dur := time.Since(start) |
| 35 | if err != nil { |
| 36 | c.log.LogAttrs(ctx, slog.LevelDebug, "github GetFiles tree failed", |
| 37 | slog.String("owner", owner), |
| 38 | slog.String("repo", repoName), |
| 39 | slog.String("commit", commit), |
| 40 | slog.String("request_id", reqID), |
| 41 | slog.Duration("duration", dur), |
| 42 | slog.String("error", err.Error()), |
| 43 | ) |
| 44 | return nil, fmt.Errorf("listing %q/%q:%q: %w", owner, repoName, commit, err) |
| 45 | } |
| 46 | c.log.LogAttrs(ctx, slog.LevelDebug, "github GetFiles tree completed", |
| 47 | slog.String("owner", owner), |
| 48 | slog.String("repo", repoName), |
| 49 | slog.String("commit", commit), |
| 50 | slog.String("request_id", reqID), |
| 51 | slog.Duration("duration", dur), |
| 52 | slog.Int("entries", len(tree.Entries)), |
| 53 | ) |
| 54 | |
| 55 | entries := content.FilterEntries(tree.Entries, func(e *github.TreeEntry) string { return e.GetPath() }, repo) |
| 56 | files, err := c.getFiles(ctx, owner, repoName, commit, entries) |
| 57 | if err != nil { |
| 58 | return nil, fmt.Errorf("downloading %q/%q:%q: %w", owner, repoName, commit, err) |
| 59 | } |
| 60 | |
| 61 | return files, nil |
| 62 | } |
| 63 | |
| 64 | func (c client) getFiles( |
| 65 | ctx context.Context, |