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

Function getCliProxyFeatureToGitHubModeCodemod

pkg/cli/codemod_cli_proxy_mode.go:12–40  ·  view source on GitHub ↗

getCliProxyFeatureToGitHubModeCodemod migrates features.cli-proxy: true to tools.github.mode: gh-proxy.

()

Source from the content-addressed store, hash-verified

10
11// getCliProxyFeatureToGitHubModeCodemod migrates features.cli-proxy: true to tools.github.mode: gh-proxy.
12func getCliProxyFeatureToGitHubModeCodemod() Codemod {
13 return Codemod{
14 ID: "features-cli-proxy-to-tools-github-mode",
15 Name: "Migrate 'features.cli-proxy: true' to 'tools.github.mode: gh-proxy'",
16 Description: "Removes deprecated features.cli-proxy: true and sets tools.github.mode: gh-proxy (equivalent behavior).",
17 IntroducedIn: "1.0.0",
18 Apply: func(content string, frontmatter map[string]any) (string, bool, error) {
19 if !hasLegacyCliProxyFeatureEnabled(frontmatter) {
20 return content, false, nil
21 }
22 hasMode := hasToolsGitHubMode(frontmatter)
23
24 newContent, applied, err := applyFrontmatterLineTransform(content, func(lines []string) ([]string, bool) {
25 result, modified := removeFieldFromBlock(lines, "cli-proxy", "features")
26 if !modified {
27 return lines, false
28 }
29 if !hasMode {
30 result = addGitHubModeGhProxyToTools(result)
31 }
32 return result, true
33 })
34 if applied {
35 cliProxyModeCodemodLog.Print("Migrated features.cli-proxy: true to tools.github.mode: gh-proxy")
36 }
37 return newContent, applied, err
38 },
39 }
40}
41
42func hasLegacyCliProxyFeatureEnabled(frontmatter map[string]any) bool {
43 featuresAny, ok := frontmatter["features"]

Callers 2

GetAllCodemodsFunction · 0.85

Calls 6

hasToolsGitHubModeFunction · 0.85
removeFieldFromBlockFunction · 0.85
PrintMethod · 0.80

Tested by 1