resolveDefaultBranchRef returns the repository's default branch name via the GitHub API. When the source field omits a branch ref we must track the repo's actual default branch (which may be "master", "trunk", etc.) rather than assuming "main". If the API lookup fails, it falls back to "main" so res
(ctx context.Context, repo string)
| 116 | // assuming "main". If the API lookup fails, it falls back to "main" so resolution |
| 117 | // can still proceed in offline or rate-limited scenarios. |
| 118 | func resolveDefaultBranchRef(ctx context.Context, repo string) string { |
| 119 | branch, err := getRepoDefaultBranchCached(ctx, repo) |
| 120 | if err != nil || strings.TrimSpace(branch) == "" { |
| 121 | updateRedirectsLog.Printf("Falling back to 'main' as default branch for %s: %v", repo, err) |
| 122 | return "main" |
| 123 | } |
| 124 | updateRedirectsLog.Printf("Resolved default branch for %s: %s", repo, branch) |
| 125 | return branch |
| 126 | } |
| 127 | |
| 128 | func extractRedirectFromContent(content string) (string, error) { |
| 129 | result, err := parser.ExtractFrontmatterFromContent(content) |
no test coverage detected