Uploaded image for project: 'Apache Rat'
  1. Apache Rat
  2. RAT-335

Patterns in .gitignore are interpreted incorrectly / enhance gitignore parsing to properly work recursively

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.15
    • 0.16
    • None
    • None

    Description

      Reproduction:
      In an empty directory put this pom.xml

      <!--
       ~ Licensed under the Apache License, Version 2.0 (the "License");
       ~ you may not use this file except in compliance with the License.
       ~ You may obtain a copy of the License at
       ~
       ~  https://www.apache.org/licenses/LICENSE-2.0
       ~
       ~ Unless required by applicable law or agreed to in writing, software
       ~ distributed under the License is distributed on an AS IS BASIS,
       ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       ~ See the License for the specific language governing permissions and
       ~ limitations under the License.
      -->
      <project>
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>nl.basjes.bugreport</groupId>
        <artifactId>dummy</artifactId>
        <version>1.0.0</version>
      </project>
      

      Create a .gitignore with only this:

      *.txt
      

      Then do

      git init .
      git add .
      git commit -m"Init"
      

      Now create 2 files that will be ignored by git

      touch one.txt 
      mkdir test
      touch test/two.txt
      
      $ git status 
      On branch main
      nothing to commit, working tree clean
      

      Important: Both .txt files are not shown because they are ignored by git.

      $ mvn org.apache.rat:apache-rat-plugin:0.15:check -X
      ...
      [INFO] Will parse SCM ignores for exclusions...
      [INFO] Parsing exclusions from /home/nbasjes/workspace/Prive/BugReports/Rat/.gitignore
      [DEBUG] Added *.txt
      ...
      [DEBUG] Implicit exclude: *.txt
      ...
      [DEBUG]  - excluded one.txt
      ...
      [DEBUG]  - included test/two.txt
      ...
      [WARNING] Files with unapproved licenses:
        test/two.txt
      

      The problem is that the test/two.txt should also be excluded.

      A while ago I wrote a gitignore module as part of this project. Note that my implementation is also not a perfect match with what git does, but it is closer.
      https://github.com/nielsbasjes/codeowners/

       

      Attachments

        Issue Links

          Activity

            People

              nielsbasjes Niels Basjes
              nielsbasjes Niels Basjes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: