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

Function renameGitHubAppIDToClientID

pkg/cli/codemod_github_app_client_id.go:58–101  ·  view source on GitHub ↗
(lines []string)

Source from the content-addressed store, hash-verified

56}
57
58func renameGitHubAppIDToClientID(lines []string) ([]string, bool) {
59 result := make([]string, 0, len(lines))
60 modified := false
61
62 inGitHubApp := false
63 var githubAppIndent string
64
65 for i, line := range lines {
66 trimmed := strings.TrimSpace(line)
67
68 if trimmed == "" {
69 result = append(result, line)
70 continue
71 }
72
73 if !strings.HasPrefix(trimmed, "#") && inGitHubApp && hasExitedBlock(line, githubAppIndent) {
74 inGitHubApp = false
75 }
76
77 if strings.HasPrefix(trimmed, "github-app:") {
78 inGitHubApp = true
79 githubAppIndent = getIndentation(line)
80 result = append(result, line)
81 continue
82 }
83
84 if inGitHubApp {
85 lineIndent := getIndentation(line)
86 if isDescendant(lineIndent, githubAppIndent) && strings.HasPrefix(trimmed, "app-id:") {
87 newLine, replaced := findAndReplaceInLine(line, "app-id", "client-id")
88 if replaced {
89 result = append(result, newLine)
90 modified = true
91 githubAppClientIDCodemodLog.Printf("Renamed github-app app-id on line %d", i+1)
92 continue
93 }
94 }
95 }
96
97 result = append(result, line)
98 }
99
100 return result, modified
101}

Callers

nothing calls this directly

Calls 5

hasExitedBlockFunction · 0.85
getIndentationFunction · 0.85
isDescendantFunction · 0.85
findAndReplaceInLineFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected