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

Function resolveRemoteSymlinkComponent

pkg/parser/remote_fetch.go:822–852  ·  view source on GitHub ↗
(
	client *api.RESTClient,
	owner, repo, filePath, ref string,
	parts []string,
	index int,
	dirPath string,
)

Source from the content-addressed store, hash-verified

820}
821
822func resolveRemoteSymlinkComponent(
823 client *api.RESTClient,
824 owner, repo, filePath, ref string,
825 parts []string,
826 index int,
827 dirPath string,
828) (string, bool, error) {
829 target, isSymlink, err := checkRemoteSymlink(client, owner, repo, dirPath, ref)
830 if err != nil {
831 if errorutil.IsNotFoundError(err) {
832 remoteLog.Printf("Path component %s returned 404, skipping", dirPath)
833 return "", false, nil
834 }
835 return "", false, fmt.Errorf("failed to check path component %s for symlinks: %w", dirPath, err)
836 }
837 if !isSymlink {
838 return "", false, nil
839 }
840 parentDir := ""
841 if index > 1 {
842 parentDir = strings.Join(parts[:index-1], "/")
843 }
844 resolvedBase, err := resolveAndValidateRemoteSymlinkBase(parentDir, target, dirPath)
845 if err != nil {
846 return "", false, err
847 }
848 remaining := strings.Join(parts[index:], "/")
849 resolvedPath := resolvedBase + "/" + remaining
850 remoteLog.Printf("Resolved symlink in remote path: %s -> %s (full: %s -> %s)", dirPath, target, filePath, resolvedPath)
851 return resolvedPath, true, nil
852}
853
854func resolveAndValidateRemoteSymlinkBase(parentDir, target, dirPath string) (string, error) {
855 remoteLog.Printf("Resolving symlink: component=%s target=%s parentDir=%s", dirPath, target, parentDir)

Callers 1

resolveRemoteSymlinksFunction · 0.85

Calls 5

IsNotFoundErrorFunction · 0.92
checkRemoteSymlinkFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected