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

Function resolveWorkspaceRoot

pkg/workflow/compiler_yaml.go:1090–1102  ·  view source on GitHub ↗

resolveWorkspaceRoot returns the workspace root directory given the path to a workflow markdown file. ImportPaths are relative to the workspace root (e.g. ".github/workflows/shared/foo.md"), so the workspace root is the directory that contains ".github/".

(markdownPath string)

Source from the content-addressed store, hash-verified

1088// file. ImportPaths are relative to the workspace root (e.g. ".github/workflows/shared/foo.md"),
1089// so the workspace root is the directory that contains ".github/".
1090func resolveWorkspaceRoot(markdownPath string) string {
1091 normalized := filepath.ToSlash(markdownPath)
1092 if before, _, ok := strings.Cut(normalized, "/.github/"); ok {
1093 // Absolute or non-root-relative path: strip everything from "/.github/" onward.
1094 return filepath.FromSlash(before)
1095 }
1096 if strings.HasPrefix(normalized, constants.GithubDir) {
1097 // Path already starts at the workspace root.
1098 return "."
1099 }
1100 // Fallback: use the directory containing the workflow file.
1101 return filepath.Dir(markdownPath)
1102}

Callers 1

generatePromptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected