Search code examples
javagroovynaming-conventionsconfiguration-filesgitignore

Gitignore like file convention


I'm developing a script with (Groovy/Java) which compare two folders and generate a diff patch file in zip format. The thing now is i have to ignore some file within the iteration because they should not be included in the patch file.

Requirement:

Create a configuration file (like gitignore file) which list the path of ignored files in the comparison process.

The problem:

I like to stick at convention/codestyle guidelines but now i cannot find any reference on how should this be done (not the code, i know how to do it) in terms of:

  1. the name, the extention and/or location of the file.
  2. the codestyle, how files should be listed (maybe i should copy gitignore pattern).
  3. Other things to consider.

I hope i've been clear and my question is within SO's topic scope.

Thanks in advance


Solution

  • 1 and 2 are addressed in gitignore man page: the .gitignore file would be part of the source files you are scanning and would apply to files from the .gitignore folder and below.

    It uses a glob pattern, like fnmatch does (meaning: no regexes).

    If it was an actual git repo, git check-ignore -v -- afile could tell you if that file is ignored or not.