giter8 icon indicating copy to clipboard operation
giter8 copied to clipboard

Template generation ignores files that "vanilla" .gitignore doesn't

Open chrisbenincasa opened this issue 6 years ago • 1 comments

Using the latest giter8 from brew (0.10.0), some file patterns in .gitignore are ignored by giter8 that wouldn't be ignored by git.

Here is an example:

Template structure:

> tree -a minimal.g8/

minimal.g8
└── src
    └── main
        └── g8
            ├── .gitignore
            ├── default.properties
            └── src
                └── main
                    └── resources
                        └── test.conf

6 directories, 3 files

.gitignore contents in scaffold:

**/resources/build.properties

Generated directory:

> g8 file://minimal.g8 --name=minimal
> tree -a minimal/

minimal/
└── .gitignore

0 directories, 1 file

Note that src/main/resources/test.conf is missing. We can verify that "normal" git would not ignore these files with git check-ignore:

✗ git check-ignore --verbose src/main/resources/test.conf
✗ git check-ignore --verbose src/main/resources/build.properties
.gitignore:1:**/resources/build.properties      src/main/resources/build.properties

chrisbenincasa avatar Jun 05 '18 21:06 chrisbenincasa

Here is another example, this time using a wildcard for filename:

Template

> tree -a minimal.g8/

minimal.g8/
└── src
    └── main
        └── g8
            ├── .gitignore
            ├── default.properties
            ├── deploy
            │   └── .gitkeep
            └── src
                └── main
                    └── resources
                        └── test.conf

7 directories, 4 files

.gitignore contents in scaffold:

deploy/*.json

Generated directory

> g8 file://minimal.g8 --name=minimal
> tree -a minimal/

minimal/
├── .gitignore
└── src
    └── main
        └── resources
            └── test.conf

3 directories, 2 files

git check-files result in generated project:

✗ git check-ignore --verbose deploy/.gitkeep
✗ git check-ignore --verbose deploy/service.json
.gitignore:1:deploy/*.json      deploy/service.json

I also verified the two ignores using JGit:

@ import org.eclipse.jgit.ignore.FastIgnoreRule
import org.eclipse.jgit.ignore.FastIgnoreRule

@ val rule = new Fast
FastIgnoreRule
@ val rule = new FastIgnoreRule("deploy/*.json")
rule: FastIgnoreRule = deploy/*.json

@ rule.isMatch("deploy/.gitkeep", false)
res3: Boolean = false

@ rule.isMatch("deploy/service.json", false)
res4: Boolean = true

@ val rule2 = new FastIgnoreRule("**/resources/build.properties")
rule2: FastIgnoreRule = **/resources/build.properties

@ rule2.isMatch("src/main/resources/build.properties", false)
res6: Boolean = true

@ rule2.isMatch("src/main/resources/test.conf", false)
res7: Boolean = false

chrisbenincasa avatar Jun 05 '18 21:06 chrisbenincasa