Have claude do some completely retarded shit
This commit is contained in:
28
util.go
28
util.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user