File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -406,6 +406,13 @@ find "$DIR_TO_CHECK" -mindepth 1 -maxdepth 1 | while read -s -r i; do
406406 # and source services on server side
407407 [ -d " $DIR_TO_CHECK /$BASE " ] && [ -d " $DIR_TO_CHECK /.old" ] && continue
408408
409+ # ignore files that are ignored by git
410+ if test -x " $( type -p git) " && test -f " $DIR_TO_CHECK /.gitignore" ; then
411+ if (cd " $DIR_TO_CHECK " && git check-ignore -q --no-index " $BASE " ); then
412+ continue
413+ fi
414+ fi
415+
409416 warn_on_unmentioned_files " $BASE "
410417
411418 if test " $RETURN " ! = " 2" ; then
Original file line number Diff line number Diff line change 3737 ./helpers/spec_query --no-conditionals --keep-name-conditionals --disambiguate-sources --specfile t/data/glibc.spec
3838 ./helpers/spec_query --no-conditionals --keep-name-conditionals --disambiguate-sources --specfile t/data/glibc.spec --buildflavor testsuite
3939 ./20-files-present-and-referenced t/data/x2d/
40+ ./t/test_gitignore.sh
4041
4142
4243.PHONY : all install package test
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Test for .gitignore integration in 20-files-present-and-referenced
3+
4+ set -e
5+
6+ # Path to the script to test
7+ VALIDATOR=" ./20-files-present-and-referenced"
8+ TEST_DATA_DIR=" t/data/gitignore_test"
9+
10+ # Create test data directory if it doesn't exist
11+ mkdir -p " $TEST_DATA_DIR "
12+ trap ' rm -rf "$TEST_DATA_DIR"' EXIT
13+
14+ # Create a dummy spec file
15+ cat > " $TEST_DATA_DIR /test.spec" << EOF
16+ Name: test
17+ Version: 1.0
18+ Release: 0
19+ Summary: test
20+ License: MIT
21+ Source0: test.tar.gz
22+ %description
23+ test
24+ %prep
25+ %setup -q
26+ %build
27+ %install
28+ %files
29+ EOF
30+
31+ touch " $TEST_DATA_DIR /test.tar.gz"
32+
33+ # Create a .gitignore and an ignored file
34+ echo " ignored.txt" > " $TEST_DATA_DIR /.gitignore"
35+ touch " $TEST_DATA_DIR /ignored.txt"
36+
37+ # Create an extra file that should NOT be ignored and NOT in spec
38+ touch " $TEST_DATA_DIR /extra.txt"
39+
40+ echo " Running validator on $TEST_DATA_DIR ..."
41+ OUTPUT=$( ./20-files-present-and-referenced --batchmode " $TEST_DATA_DIR " 2>&1 )
42+
43+ echo " Output:"
44+ echo " $OUTPUT "
45+
46+ # Verification
47+ RET=0
48+
49+ if echo " $OUTPUT " | grep -q " ignored.txt" ; then
50+ echo " FAIL: ignored.txt should have been ignored but was mentioned in output"
51+ RET=1
52+ fi
53+
54+ if ! echo " $OUTPUT " | grep -q " extra.txt" ; then
55+ echo " FAIL: extra.txt should have been mentioned in output but was not"
56+ RET=1
57+ fi
58+
59+ if [ $RET -eq 0 ]; then
60+ echo " SUCCESS: gitignore filtering works correctly"
61+ else
62+ echo " FAILURE: gitignore filtering test failed"
63+ fi
64+
65+ exit $RET
You can’t perform that action at this time.
0 commit comments