Skip to content

Commit

Permalink
Fixed some minor issues where .gitignore was not always respected
Browse files Browse the repository at this point in the history
  • Loading branch information
aerugo committed Jul 23, 2024
1 parent 3ecbd94 commit ac2611d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 5 additions & 1 deletion prelude
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ add_patterns_from_file() {
while IFS= read -r line || [[ -n "$line" ]]; do
line=$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ ! "$line" =~ ^#.*$ ]] && [[ -n "$line" ]]; then
# if line starts with /, remove it
if [[ "$line" == /* ]]; then
line=${line:1}
fi
IFS='|' read -ra existing_patterns <<< "$exclude_patterns"
if ! [[ " ${existing_patterns[*]} " =~ " ${line} " ]]; then
exclude_patterns=${exclude_patterns:+"$exclude_patterns|"}$line
Expand Down Expand Up @@ -150,7 +154,7 @@ output_filename=""
tree_pattern=""
git_only=false
case_sensitive=false
exclude_patterns="prelude|.preludeignore|.gitignore"
exclude_patterns="prelude|.git|.preludeignore|.gitignore"

# Parse command line arguments
while getopts ":P:F:M:cgC-:" opt; do
Expand Down
14 changes: 3 additions & 11 deletions test_prelude.bats
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,11 @@ teardown() {
[ -f output.txt ]
cat output.txt
grep -q "Hello, world!" output.txt
#grep -q "print('Hello')" output.txt
#grep -q "function test() {}" output.txt
#! grep -q "This file is not tracked" output.txt
grep -q "print('Hello')" output.txt
grep -q "function test() {}" output.txt
! grep -q "This file is not tracked" output.txt
}


@test "Script handles empty files" {
touch src/empty.txt
run ./prelude -P src -F output.txt
Expand Down Expand Up @@ -269,13 +268,6 @@ teardown() {
git add src/.hidden_dir/file.txt
git commit -m "Add hidden files"
run ./prelude -g -F output.txt
echo "Listing files:"
ls -a src
echo "Listing git files:"
git ls-files .
echo "Output:"
cat output.txt
echo "End of output"
[ "$status" -eq 0 ]
[[ "$output" == *"src/.hidden_file"* ]]
[[ "$output" == *"src/.hidden_dir/file.txt"* ]]
Expand Down

0 comments on commit ac2611d

Please sign in to comment.