hasDeprecatedGitHubReposField returns true if tools.github has a deprecated 'repos' field and does not already have an 'allowed-repos' field.
(frontmatter map[string]any)
| 32 | // hasDeprecatedGitHubReposField returns true if tools.github has a deprecated 'repos' field |
| 33 | // and does not already have an 'allowed-repos' field. |
| 34 | func hasDeprecatedGitHubReposField(frontmatter map[string]any) bool { |
| 35 | toolsAny, hasTools := frontmatter["tools"] |
| 36 | if !hasTools { |
| 37 | return false |
| 38 | } |
| 39 | toolsMap, ok := toolsAny.(map[string]any) |
| 40 | if !ok { |
| 41 | return false |
| 42 | } |
| 43 | githubAny, hasGitHub := toolsMap["github"] |
| 44 | if !hasGitHub { |
| 45 | return false |
| 46 | } |
| 47 | githubMap, ok := githubAny.(map[string]any) |
| 48 | if !ok { |
| 49 | return false |
| 50 | } |
| 51 | _, hasRepos := githubMap["repos"] |
| 52 | _, hasAllowedRepos := githubMap["allowed-repos"] // only check existence, not value |
| 53 | if hasRepos && !hasAllowedRepos { |
| 54 | githubReposCodemodLog.Print("Deprecated 'repos' field found in tools.github") |
| 55 | } |
| 56 | return hasRepos && !hasAllowedRepos |
| 57 | } |
| 58 | |
| 59 | // renameGitHubReposToAllowedRepos renames 'repos:' to 'allowed-repos:' within the |
| 60 | // tools.github configuration block. |
no test coverage detected