Yet another fix for ProjectDirectoryTree.

This commit is contained in:
Martín Lucas Golini
2024-03-16 22:16:04 -03:00
parent eb19d5d8ee
commit bacbf35a9c
3 changed files with 14 additions and 11 deletions
+6 -4
View File
@@ -11,12 +11,16 @@ IgnoreMatcher::IgnoreMatcher( const std::string& rootPath ) : mPath( rootPath )
IgnoreMatcher::~IgnoreMatcher() {}
GitIgnoreMatcher::GitIgnoreMatcher( const std::string& rootPath,
const std::string& ignoreFileName ) :
GitIgnoreMatcher::GitIgnoreMatcher( const std::string& rootPath, const std::string& ignoreFileName,
bool addGitFolderFilter ) :
IgnoreMatcher( rootPath ),
mIgnoreFileName( ignoreFileName ),
mIgnoreFilePath( mPath + mIgnoreFileName ) {
if ( canMatch() ) {
if ( addGitFolderFilter ) {
if ( FileSystem::fileExists( mPath + ".git" ) ) // Also ignore the .git folder
mPatterns.emplace_back( std::make_pair( ".git/**", false ) );
}
if ( parse() ) {
mMatcherReady = true;
}
@@ -34,8 +38,6 @@ const std::string& GitIgnoreMatcher::getIgnoreFilePath() const {
bool GitIgnoreMatcher::parse() {
std::string patternFile;
FileSystem::fileGet( mPath + mIgnoreFileName, patternFile );
if ( FileSystem::fileExists( mPath + ".git" ) ) // Also ignore the .git folder
mPatterns.emplace_back( std::make_pair( "**/.git/**", false ) );
std::vector<std::string> patterns = String::split( patternFile );
for ( auto& pattern : patterns ) {
bool negates = false;