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

Function resolveRemoteNestedPath

pkg/parser/import_bfs.go:423–438  ·  view source on GitHub ↗
(item importQueueItem, nestedFilePath string)

Source from the content-addressed store, hash-verified

421}
422
423func resolveRemoteNestedPath(item importQueueItem, nestedFilePath string) (string, *remoteImportOrigin, error) {
424 cleanPath := path.Clean(strings.TrimPrefix(nestedFilePath, "./"))
425 if cleanPath == ".." || strings.HasPrefix(cleanPath, "../") || path.IsAbs(cleanPath) {
426 return "", nil, fmt.Errorf("nested import '%s' from remote file '%s' escapes base directory", nestedFilePath, item.importPath)
427 }
428 basePath := item.remoteOrigin.BasePath
429 if basePath == "" {
430 basePath = constants.GetWorkflowDir()
431 }
432 basePath = path.Clean(basePath)
433 resolvedPath := fmt.Sprintf("%s/%s/%s/%s@%s",
434 item.remoteOrigin.Owner, item.remoteOrigin.Repo, basePath, cleanPath, item.remoteOrigin.Ref)
435 nestedRemoteOrigin := parseRemoteOrigin(resolvedPath)
436 importLog.Printf("Resolving nested import as remote workflowspec: %s -> %s (basePath=%s)", nestedFilePath, resolvedPath, basePath)
437 return resolvedPath, nestedRemoteOrigin, nil
438}
439
440func determineNestedBaseDir(item importQueueItem, resolvedPath, baseDir string) string {
441 isLocalRelative := !strings.Contains(resolvedPath, "/") || strings.HasPrefix(resolvedPath, "./")

Callers 1

Calls 4

GetWorkflowDirFunction · 0.92
parseRemoteOriginFunction · 0.85
ErrorfMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected