(
directive *ImportDirectiveMatch,
baseDir string,
extractTools bool,
visited map[string]struct {
})
| 127 | } |
| 128 | |
| 129 | func 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 | |
| 163 | func splitIncludePathAndSection(includePath string) (string, string) { |
| 164 | if strings.Contains(includePath, "#") { |
no test coverage detected