wfxr.forgit/tests/clean-select-files.test.sh
sandr01d b9ed7bc40e
Fix: preview for clean when file names contain backslashes (#465)
This is a breaking change: flag arguments provided to forgit clean are
now passed to git ls-files instead of git clean -n. This change is
necessary because git clean does not have a -z option that would prevent
it from escaping file names containing backslashes. However, git ls-files
is way more flexible than git clean, so all use cases covered by git
clean (and more) should still be possible.
2025-12-05 22:58:46 +01:00

33 lines
677 B
Bash

#!/usr/bin/env bash
function set_up_before_script() {
source bin/git-forgit
# create a new git repository in a temp directory
cd "$(temp_dir)" || return 1
git init --quiet
# create files to test against
touch file.txt
touch file_with\\backslashes\\.txt
touch "file with spaces.txt"
touch "file_with\ttab.txt"
}
# @data_provider provider_clean_select_files
function test_forgit_clean_select_files_preview() {
mock "fzf" "sed -n ${1}p"
local file
file=$(_forgit_clean_select_files)
assert_file_exists "$file"
}
function provider_clean_select_files() {
data_set 1
data_set 2
data_set 3
data_set 4
}