diff --git a/.gitignore b/.gitignore index 1ec6a30b7..9eee44e3b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ cli-test/.rspec_status # Ignore data in fixtures, retain script to generate fixtures through cloning cli-test/spec/fixtures/* !cli-test/spec/fixtures/create_fixtures.sh +cli-test/vendor/ # Per-project Cargo config # We're currently only using this for configuring mold/sold for local diff --git a/cli-test/spec/test_cases/rm/tests.rb b/cli-test/spec/test_cases/rm/tests.rb index 8f50375e7..83ce8746c 100644 --- a/cli-test/spec/test_cases/rm/tests.rb +++ b/cli-test/spec/test_cases/rm/tests.rb @@ -56,4 +56,31 @@ expect(File.exist?(File.join(directory_path, 'root.txt'))).to be false expect(File.exist?(File.join(directory_path, 'images/test/nested.txt'))).to be false end + + it 'tests oxen rm with removed path from disk' do + directory_path = 'tmp/aruba/test-removed-path' + + # Setup base repo + run_command_and_stop('mkdir test-removed-path') + cd 'test-removed-path' + run_command_and_stop('oxen init') + + # Create and commit root file + file_path = File.join(directory_path, 'root.txt') + File.open(file_path, 'w') do |file| + file.puts 'root file' + end + run_command_and_stop('oxen add root.txt') + run_command_and_stop('oxen commit -m "adding root file"') + + # Test removing file before running oxen rm + run_command_and_stop('rm root.txt') + run_command_and_stop('oxen rm root.txt') + + # Should show files as removed in staging + expect(last_command_started).to have_output(/removed 1 file/) + + # Files should not exist on disk + expect(File.exist?(File.join(directory_path, 'root.txt'))).to be false + end end \ No newline at end of file diff --git a/src/cli/src/cmd/add.rs b/src/cli/src/cmd/add.rs index 5a2617494..dfb9ae081 100644 --- a/src/cli/src/cmd/add.rs +++ b/src/cli/src/cmd/add.rs @@ -48,18 +48,7 @@ impl RunCmd for AddCmd { OxenError::basic_str(format!("Failed to get current directory: {}", e)) })?; let joined_path = current_dir.join(p); - joined_path.canonicalize().map_err(|e| { - log::warn!( - "Failed to canonicalize path {}: {}", - joined_path.display(), - e - ); - OxenError::basic_str(format!( - "Failed to canonicalize path {}: {}", - joined_path.display(), - e - )) - }) + joined_path.canonicalize().or_else(|_| Ok(joined_path)) }) .collect::, OxenError>>()?; diff --git a/src/cli/src/cmd/rm.rs b/src/cli/src/cmd/rm.rs index 572761e80..a68d8fa20 100644 --- a/src/cli/src/cmd/rm.rs +++ b/src/cli/src/cmd/rm.rs @@ -52,18 +52,7 @@ impl RunCmd for RmCmd { OxenError::basic_str(format!("Failed to get current directory: {}", e)) })?; let joined_path = current_dir.join(p); - joined_path.canonicalize().map_err(|e| { - log::warn!( - "Failed to canonicalize path {}: {}", - joined_path.display(), - e - ); - OxenError::basic_str(format!( - "Failed to canonicalize path {}: {}", - joined_path.display(), - e - )) - }) + joined_path.canonicalize().or_else(|_| Ok(joined_path)) }) .collect::, OxenError>>()?;