This fixes a bug where calling FSProject.files with a single file for the
second time would return all files in the directory instead of that single
file. This is because in case of a single file the original implementation
would overwrite @path with the directory of the single file. The next time
FSProject.files is called, @path is not a file anymore, and the pattern
will be set to "*", matching all files.
Fix this by splitting the path into directory and pattern, and always
constructing the path from these.
This is a performance optimization to avoid expressions like "files.empty?
|| files.nil?" like in "project.rb" to trigger the creation of the list of
files multiple times.
As a side effect, this fixes a bug where calling FSProject.files with a
single file for the second time would return all files in the directory
instaed of that single file. This is because in case of a single file the
implementation overwrites @path with the directory of the single file.
The next time FSProject.files is called, @path is not a file anymore, and
the pattern will be set to "*", matching all files.
This change implements the following ranking:
1. No extension: LICENSE, COPYING, etc.
3. Filetype extension (syntactic annotation): UNLICENSE.txt, COPYRIGHT.md, etc.
2. Content-related extension (semantic annotation): COPYING.image, LICENCE.go, etc.
This is useful if you alread know the path to the license file (or want to
ensure the license file exists at the given path) and just want to check
for the type of license.
As regular local Git repositories have working trees that could also be
processed by an FSProject, the main advantage of GitProject is that it can
handle bare repositories without actually checking the files out into a
working tree.