|
15 | 15 | #include <string> |
16 | 16 | #include <chrono> |
17 | 17 | #include <format> |
| 18 | +#include <cstring> |
18 | 19 |
|
19 | 20 | #include <filesystem> |
20 | 21 | namespace fs = std::filesystem; |
@@ -107,6 +108,35 @@ int main(int argc, char const * argv[]) { |
107 | 108 | throw bad_issue_file{filename, "Corrupt status attribute"}; |
108 | 109 | } |
109 | 110 | auto old_status = issue_data.substr(k, l-k); |
| 111 | + |
| 112 | + // Do not allow an IS status for TS issues, and vice versa. |
| 113 | + if (new_status.starts_with("C++") or new_status == "TS") |
| 114 | + { |
| 115 | + auto t1 = issue_data.find("<title>", l); |
| 116 | + auto t2 = issue_data.find("</title>", l); |
| 117 | + if (t1 == std::string::npos or t2 == std::string::npos or t2 < t1) |
| 118 | + throw bad_issue_file{filename, "Cannot find <title> element"}; |
| 119 | + t1 += std::strlen("<title>"); |
| 120 | + std::string_view title(issue_data); |
| 121 | + title = title.substr(t1, t2 - t1); |
| 122 | + bool is_ts_issue = false; |
| 123 | + if (title.starts_with('[')) |
| 124 | + { |
| 125 | + auto end = title.find(']'); |
| 126 | + if (end != title.npos) |
| 127 | + { |
| 128 | + auto tag = title.substr(0, end); |
| 129 | +#ifdef __cpp_lib_string_contains |
| 130 | + is_ts_issue = tag.contains(".ts"); |
| 131 | +#else |
| 132 | + is_ts_issue = tag.find(".ts") != tag.npos; |
| 133 | +#endif |
| 134 | + } |
| 135 | + } |
| 136 | + if (is_ts_issue != (new_status == "TS")) |
| 137 | + throw std::runtime_error{std::format("Refusing to set status \"{}\" for issue in {}:\n\t{}: {}", new_status, is_ts_issue ? "a TS" : "the IS", issue_number, title)}; |
| 138 | + } |
| 139 | + |
110 | 140 | issue_data.replace(k, l-k, new_status); |
111 | 141 |
|
112 | 142 | if (lwg::filename_for_status(new_status) != lwg::filename_for_status(old_status)) { |
|
0 commit comments