From c26a8fb4cee1380b2e828203849dd13a54749e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 24 Nov 2022 13:45:57 +0100 Subject: [PATCH] Fixed #11395 (Cant exclude file) --- cli/filelister.cpp | 3 +++ test/testfilelister.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/cli/filelister.cpp b/cli/filelister.cpp index 2c7093fcc..2caf0ea98 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -182,6 +182,9 @@ static std::string addFiles2(std::map &files, const PathMatch& ignored ) { + if (ignored.match(path)) + return ""; + struct stat file_stat; if (stat(path.c_str(), &file_stat) != -1) { if ((file_stat.st_mode & S_IFMT) == S_IFDIR) { diff --git a/test/testfilelister.cpp b/test/testfilelister.cpp index 44fb779ce..ddd464578 100644 --- a/test/testfilelister.cpp +++ b/test/testfilelister.cpp @@ -43,6 +43,7 @@ private: TEST_CASE(isDirectory); TEST_CASE(recursiveAddFiles); + TEST_CASE(excludeFile); TEST_CASE(fileExists); } @@ -78,6 +79,15 @@ private: ASSERT(files.find("lib/tokenize.h") == files.end()); } + void excludeFile() const { + std::map files; + std::vector ignored{"lib/token.cpp"}; + PathMatch matcher(ignored); + std::string err = FileLister::recursiveAddFiles(files, "lib/token.cpp", matcher); + ASSERT(err.empty()); + ASSERT(files.empty()); + } + void fileExists() const { ASSERT_EQUALS(false, FileLister::fileExists("lib")); ASSERT_EQUALS(true, FileLister::fileExists("readme.txt"));