From 3b4ea3f42d46889268906c7767d748d081d354c7 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 7 Mar 2022 23:06:10 +0100 Subject: [PATCH] Manager: Rename filter() -> match() The function returns true on a pattern match, so reflect this in the name. --- src/dotfile.cpp | 6 +++--- src/dotfile.h | 4 ++-- test/unit/testdotfile.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dotfile.cpp b/src/dotfile.cpp index ea2640d..87c11aa 100644 --- a/src/dotfile.cpp +++ b/src/dotfile.cpp @@ -106,7 +106,7 @@ void Dotfile::push(const std::vector& targets) pullOrPush(SyncType::Push, targets); } -bool Dotfile::filter(const std::filesystem::directory_entry& path, +bool Dotfile::match(const std::filesystem::directory_entry& path, const std::vector& patterns) { std::string pathString = path.path().string(); @@ -490,11 +490,11 @@ void Dotfile::forEachDotfile(const std::vector& targets, const std: continue; } // Ignore pattern check - if (filter(path, Config::the().ignorePatterns())) { + if (match(path, Config::the().ignorePatterns())) { continue; } // Include check - if (!targets.empty() && !filter(path, targets)) { + if (!targets.empty() && !match(path, targets)) { continue; } callback(path, index++); diff --git a/src/dotfile.h b/src/dotfile.h index 449df01..6ec2869 100644 --- a/src/dotfile.h +++ b/src/dotfile.h @@ -30,8 +30,8 @@ public: void pull(const std::vector& targets = {}); void push(const std::vector& targets = {}); - bool filter(const std::filesystem::directory_entry& path, - const std::vector& patterns); + bool match(const std::filesystem::directory_entry& path, + const std::vector& patterns); private: void pullOrPush(SyncType type, const std::vector& targets = {}); diff --git a/test/unit/testdotfile.cpp b/test/unit/testdotfile.cpp index 2fe8a2a..fb08365 100644 --- a/test/unit/testdotfile.cpp +++ b/test/unit/testdotfile.cpp @@ -94,7 +94,7 @@ void testDotfileFilters(const std::unordered_map& tests, createTestDotfiles(fileNames, fileContents); for (const auto& path : fileNames) { - bool result = Dotfile::the().filter(std::filesystem::directory_entry { "/" + path }, testIgnorePatterns); + bool result = Dotfile::the().match(std::filesystem::directory_entry { "/" + path }, testIgnorePatterns); EXPECT_EQ(result, tests.at(path), printf(" path = '%s'\n", path.c_str())); }