MCPcopy Create free account
hub / github.com/github/gh-aw / getGitHubReposToAllowedReposCodemod

Function getGitHubReposToAllowedReposCodemod

pkg/cli/codemod_github_repos.go:13–30  ·  view source on GitHub ↗

getGitHubReposToAllowedReposCodemod creates a codemod that renames the deprecated 'repos:' field to 'allowed-repos:' within the tools.github configuration block.

()

Source from the content-addressed store, hash-verified

11// getGitHubReposToAllowedReposCodemod creates a codemod that renames the deprecated
12// 'repos:' field to 'allowed-repos:' within the tools.github configuration block.
13func 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.

Callers 2

GetAllCodemodsFunction · 0.85

Calls 3

PrintMethod · 0.80

Tested by 1