`crafter-build format --check format` read the second `format` as the verb again, which set the mode back to applying and recorded no glob, so it ran every transform and rewrote the project's sources, and exited 0, though `--check` writes nothing. FormatCheckGlob drives Run() on a staged project whose one rule, named "format", would change its main.cpp, and holds the run to exiting 1, the check with a file to change, with main.cpp as it was. It fails before the verb enum of the commit before this one and passes with it.
24 lines
962 B
C++
24 lines
962 B
C++
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
import std;
|
|
import Crafter.Build;
|
|
using namespace Crafter;
|
|
|
|
// One source and one transform, named "format", that would change it: it
|
|
// ends every file with a marker line the fixture's main.cpp lacks.
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = "format-check";
|
|
cfg.outputName = "format-check";
|
|
cfg.type = ConfigurationType::Executable;
|
|
ApplyStandardArgs(cfg, args);
|
|
std::array<std::filesystem::path, 0> interfaces = {};
|
|
std::array<std::filesystem::path, 1> implementations = { "main" };
|
|
cfg.GetInterfacesAndImplementations(interfaces, implementations);
|
|
cfg.AddLintRule("format", [](LintContext& ctx) {
|
|
if (!ctx.content.ends_with("// formatted\n")) ctx.SetContent(ctx.content + "// formatted\n");
|
|
});
|
|
return cfg;
|
|
}
|