xaizek / zograscope (License: AGPLv3 only) (since 2018-12-07)
Mainly a syntax-aware diff that also provides a number of additional tools.
Commit c1fdd64b0839660b22889d576286cb71b0e8904e

Fix .zs/exclude affecting explicitly specified paths
Author: xaizek
Author date (UTC): 2022-04-25 11:56
Committer name: xaizek
Committer date (UTC): 2022-04-25 11:56
Parent(s): ec1d0c4a99aa08a861cb08451580bdaa9afa23fb
Signing key: 99DC5E4DB05F6BE2
Tree: 7d596f51f71779af171aa8a539d8d63afaac3c2b
File Lines added Lines deleted
src/tooling/Traverser.cpp 4 4
tests/tooling/Traverser.cpp 23 0
File src/tooling/Traverser.cpp changed (mode: 100644) (index dd0ada6..654e13e)
... ... Traverser::search()
53 53 bool bool
54 54 Traverser::search(const boost::filesystem::path &path) Traverser::search(const boost::filesystem::path &path)
55 55 { {
56 auto match = [this](const std::string &file) {
57 if (!config.shouldProcessFile(file)) {
56 auto match = [this](const std::string &file, bool passedIn) {
57 if (!passedIn && !config.shouldProcessFile(file)) {
58 58 return false; return false;
59 59 } }
60 60
 
... ... Traverser::search(const boost::filesystem::path &path)
66 66 }; };
67 67
68 68 if (!fs::is_directory(path)) { if (!fs::is_directory(path)) {
69 return match(path.string());
69 return match(path.string(), /*passedIn=*/true);
70 70 } }
71 71
72 72 using it = fs::directory_iterator; using it = fs::directory_iterator;
 
... ... Traverser::search(const boost::filesystem::path &path)
79 79 found |= search(path); found |= search(path);
80 80 } }
81 81 } else { } else {
82 found |= match(path.string());
82 found |= match(path.string(), /*passedIn=*/false);
83 83 } }
84 84 } }
85 85 return found; return found;
File tests/tooling/Traverser.cpp changed (mode: 100644) (index f508763..c128efd)
23 23
24 24 #include "tests.hpp" #include "tests.hpp"
25 25
26 TEST_CASE("Traverser doesn't exclude passed in paths", "[tooling][traverser]")
27 {
28 TempDir tempDir("config");
29 REQUIRE(boost::filesystem::create_directory(tempDir.str() + "/.zs"));
30 makeFile(tempDir.str() + "/.zs/exclude", { "test.c" });
31 std::string file = tempDir.str() + "/test.c";
32 makeFile(file, { });
33
34 std::vector<std::string> paths;
35 auto handler = [&](const std::string &path) {
36 paths.push_back(path);
37 return true;
38 };
39
40 Chdir chdirInsideTmpDir(tempDir.str());
41 Environment env;
42
43 CHECK(!Traverser({ tempDir }, "", env.getConfig(), handler).search());
44 CHECK(paths.size() == 0);
45 CHECK(Traverser({ file }, "", env.getConfig(), handler).search());
46 CHECK(paths.size() == 1);
47 }
48
26 49 TEST_CASE("Traverser accounts for lang attribute", "[tooling][traverser]") TEST_CASE("Traverser accounts for lang attribute", "[tooling][traverser]")
27 50 { {
28 51 TempDir tempDir("config"); TempDir tempDir("config");
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/zograscope

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/zograscope

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master