( client *api.RESTClient, owner, repo, filePath, ref string, parts []string, index int, dirPath string, )
| 820 | } |
| 821 | |
| 822 | func 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 | |
| 854 | func resolveAndValidateRemoteSymlinkBase(parentDir, target, dirPath string) (string, error) { |
| 855 | remoteLog.Printf("Resolving symlink: component=%s target=%s parentDir=%s", dirPath, target, parentDir) |
no test coverage detected