Have claude do some completely retarded shit

This commit is contained in:
2025-11-11 13:00:04 +01:00
parent ade7c4d2b2
commit d8de4717e2
5 changed files with 339 additions and 50 deletions

28
util.go
View File

@@ -71,6 +71,34 @@ func ConvertHome(input string) (string, error) {
return input, nil
}
// ResolvePath resolves a path according to the following rules:
// 1. If path starts with ~/, replace ~ with user's home directory
// 2. If path is absolute, return as-is
// 3. If path is relative, join it with the provided base directory
// This function ensures tilde expansion happens BEFORE path joining to avoid the bug
// where ~/path becomes /base/dir/~/path instead of /home/user/path
func ResolvePath(path, baseDir string) string {
// First, convert any tilde to home directory
if strings.HasPrefix(path, "~/") {
homedir, err := os.UserHomeDir()
if err != nil {
LogError("unable to get user home directory: %v", err)
// Fall back to treating as relative path
} else {
path = strings.Replace(path, "~", homedir, 1)
return path // After tilde expansion, it's an absolute path
}
}
// If it's already absolute, return as-is
if filepath.IsAbs(path) {
return path
}
// Otherwise, it's relative - join with base directory
return filepath.Join(baseDir, path)
}
func GetSyncFilesRecursively(input string, output chan string, status chan error) {
defer close(output)
defer close(status)