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

Function resolveDirectiveWithVisited

pkg/parser/include_processor.go:129–161  ·  view source on GitHub ↗
(
	directive *ImportDirectiveMatch,
	baseDir string,
	extractTools bool,
	visited map[string]struct {
	})

Source from the content-addressed store, hash-verified

127}
128
129func resolveDirectiveWithVisited(
130 directive *ImportDirectiveMatch,
131 baseDir string,
132 extractTools bool,
133 visited map[string]struct {
134 }) (includeDirectiveResolution, bool, error) {
135 filePath, sectionName := splitIncludePathAndSection(directive.Path)
136 fullPath, err := ResolveIncludePath(filePath, baseDir, nil)
137 if err != nil {
138 includeLog.Printf("Failed to resolve include path '%s': %v", filePath, err)
139 if directive.IsOptional {
140 if !extractTools {
141 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Optional include file not found: %s. You can create this file to configure the workflow.", filePath)))
142 }
143 return includeDirectiveResolution{}, true, nil
144 }
145 return includeDirectiveResolution{}, false, fmt.Errorf("failed to resolve required include '%s': %w", filePath, err)
146 }
147
148 if setutil.Contains(visited, fullPath) {
149 includeLog.Printf("Skipping already included file: %s", fullPath)
150 if !extractTools {
151 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Already included: %s, skipping", filePath)))
152 }
153 return includeDirectiveResolution{}, true, nil
154 }
155
156 return includeDirectiveResolution{
157 filePath: filePath,
158 sectionName: sectionName,
159 fullPath: fullPath,
160 }, false, nil
161}
162
163func splitIncludePathAndSection(includePath string) (string, string) {
164 if strings.Contains(includePath, "#") {

Callers 1

Calls 6

FormatInfoMessageFunction · 0.92
ContainsFunction · 0.92
ResolveIncludePathFunction · 0.70
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected