Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tools/Versions.cpp
diff options
context:
space:
mode:
authorLeitwolf112026-11-01 22:58:30 +0300
committerLeitwolf112026-11-01 22:58:30 +0300
commite66db1cf17714be2ebfeab37670ef3d8965fc7cc (patch)
tree88a8b55a14e9bc6152608662d062c1624c2863cf /tools/Versions.cpp
parente32c9d107274f42b9cca700475404c80e96533c5 (diff)
downloadcatch3-e66db1cf17714be2ebfeab37670ef3d8965fc7cc.tar.gz
Answer the review of the tools
repo_info starts Git in the checkout with fixed commands, so a shell never reads a path, reports an unknown state as null rather than clean, and counts only files it can start. third_party reads every archive before it changes a file and refuses two modes. version checks that the sources make a distribution, computes every place before writing any, and release_notes finds a three-number heading for a version with D = 0.
Diffstat (limited to 'tools/Versions.cpp')
-rw-r--r--tools/Versions.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/tools/Versions.cpp b/tools/Versions.cpp
index 73a2d663..abc6d5b3 100644
--- a/tools/Versions.cpp
+++ b/tools/Versions.cpp
@@ -4,6 +4,8 @@
#include <algorithm>
#include <cctype>
#include <charconv>
+#include <utility>
+#include <vector>
#include "tools/Versions.hpp"
@@ -176,24 +178,50 @@ namespace Progmasoft::Catch3::Tools
const std::string &version,
Problems &problems)
{
+ std::vector<std::pair<std::filesystem::path, std::string>> writes;
for (const auto &site : VersionSites())
{
const auto path = root / site.File;
- const auto text
+ auto text
= WriteVersionSite(ReadOrReport(path, problems), site, version);
- if (!text || !WriteText(path, *text))
+ if (text)
+ {
+ writes.emplace_back(path, *std::move(text));
+ }
+ else
{
problems.push_back("cannot set the version in "
+ std::string{ site.File });
}
}
+ // All of them or none, so that the places never disagree.
+ if (!problems.empty())
+ {
+ return;
+ }
+ for (const auto &[path, text] : writes)
+ {
+ if (!WriteText(path, text))
+ {
+ problems.push_back("cannot write " + path.generic_string());
+ }
+ }
}
std::optional<std::string>
ReleaseNotesOf(std::string_view notes, std::string_view version)
{
- const auto heading = "\n## " + std::string{ version } + "\n";
- const auto found = notes.find(heading);
+ auto heading = "\n## " + std::string{ version } + "\n";
+ auto found = notes.find(heading);
+ // A release with D = 0 may be headed by its three numbers.
+ const auto parsed = ParseVersion(version);
+ if (found == std::string_view::npos && parsed && (*parsed)[3] == 0)
+ {
+ heading = "\n## " + std::to_string((*parsed)[0]) + "."
+ + std::to_string((*parsed)[1]) + "."
+ + std::to_string((*parsed)[2]) + "\n";
+ found = notes.find(heading);
+ }
if (found == std::string_view::npos)
{
return std::nullopt;