Niels Basjes created RAT-335:
--------------------------------

             Summary: Patterns in .gitignore are interpreted incorrectly
                 Key: RAT-335
                 URL: https://issues.apache.org/jira/browse/RAT-335
             Project: Apache Rat
          Issue Type: Bug
            Reporter: Niels Basjes


Reproduction:
In an empty directory put this *pom.xml*
{code: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>
{code}
Create a *.gitignore* with only this:
{code:java}
*.txt
{code}
Then do
{code:bash}
git init .
git add .
git commit -m"Init"
{code}
Now create 2 files that will be ignored by git
{code:bash}
touch one.txt 
mkdir test
touch test/two.txt
{code}
{code:java}
$ git status 
On branch main
nothing to commit, working tree clean
{code}
{*}Important{*}: Both .txt files are not shown because they are ignored by git.
{code:java}
$ 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
{code}
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/]

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to