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

Function cleanupAllIncludes

pkg/cli/remove_command.go:367–395  ·  view source on GitHub ↗

cleanupAllIncludes removes all include files when no workflows remain

(verbose bool)

Source from the content-addressed store, hash-verified

365
366// cleanupAllIncludes removes all include files when no workflows remain
367func cleanupAllIncludes(verbose bool) error {
368 workflowsDir := constants.GetWorkflowDir()
369
370 err := filepath.Walk(workflowsDir, func(path string, info os.FileInfo, err error) error {
371 if err != nil {
372 return err
373 }
374
375 if !info.IsDir() && strings.HasSuffix(info.Name(), ".md") {
376 relPath, _ := filepath.Rel(workflowsDir, path)
377
378 // Only remove files in subdirectories (like shared/) as these are include files
379 // Root-level .md files are workflow files, not include files
380 if strings.Contains(relPath, string(filepath.Separator)) {
381 if err := os.Remove(path); err != nil {
382 if verbose {
383 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to remove include %s: %v", relPath, err)))
384 }
385 } else {
386 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Removed include: "+relPath))
387 }
388 }
389 }
390
391 return nil
392 })
393
394 return err
395}
396
397// findIncludesInContent finds all import references in content
398func findIncludesInContent(content string) ([]string, error) {

Callers 1

cleanupOrphanedIncludesFunction · 0.85

Calls 3

GetWorkflowDirFunction · 0.92
FormatWarningMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92

Tested by

no test coverage detected