getGitHubReposToAllowedReposCodemod creates a codemod that renames the deprecated 'repos:' field to 'allowed-repos:' within the tools.github configuration block.
()
| 11 | // getGitHubReposToAllowedReposCodemod creates a codemod that renames the deprecated |
| 12 | // 'repos:' field to 'allowed-repos:' within the tools.github configuration block. |
| 13 | func getGitHubReposToAllowedReposCodemod() Codemod { |
| 14 | return Codemod{ |
| 15 | ID: "github-repos-to-allowed-repos", |
| 16 | Name: "Rename 'tools.github.repos' to 'tools.github.allowed-repos'", |
| 17 | Description: "Renames the deprecated 'repos:' field to 'allowed-repos:' inside the tools.github configuration block.", |
| 18 | IntroducedIn: "1.0.0", |
| 19 | Apply: func(content string, frontmatter map[string]any) (string, bool, error) { |
| 20 | if !hasDeprecatedGitHubReposField(frontmatter) { |
| 21 | return content, false, nil |
| 22 | } |
| 23 | newContent, applied, err := applyFrontmatterLineTransform(content, renameGitHubReposToAllowedRepos) |
| 24 | if applied { |
| 25 | githubReposCodemodLog.Print("Renamed 'tools.github.repos' to 'tools.github.allowed-repos'") |
| 26 | } |
| 27 | return newContent, applied, err |
| 28 | }, |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // hasDeprecatedGitHubReposField returns true if tools.github has a deprecated 'repos' field |
| 33 | // and does not already have an 'allowed-repos' field. |