Skip to content

Commit 5737a9b

Browse files
committed
manual revision fetching
1 parent ab6bb43 commit 5737a9b

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/rman_rads.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ struct Main {
6060
}
6161

6262
auto make_realm_filter() const noexcept -> RMAN::Filter {
63+
constexpr auto RE_FLAGS = std::regex::optimize | std::regex::icase | std::regex::basic;
64+
if (cli.inrelease.ends_with('/')) {
65+
return RMAN::Filter{
66+
.path = std::regex{cli.inrelease + ".*", RE_FLAGS},
67+
};
68+
}
6369
if (auto [realm, rest] = str_split(cli.inrelease, "projects/"); !realm.empty() && !rest.empty()) {
6470
return RMAN::Filter{
65-
.path = std::regex{std::string(realm) + ".*", std::regex::optimize | std::regex::icase},
71+
.path = std::regex{std::string(realm) + ".*", RE_FLAGS},
6672
};
6773
}
6874
if (auto [realm, rest] = str_split(cli.inrelease, "solutions/"); !realm.empty() && !rest.empty()) {
6975
return RMAN::Filter{
70-
.path = std::regex{std::string(realm) + ".*", std::regex::optimize | std::regex::icase},
76+
.path = std::regex{std::string(realm) + ".*", RE_FLAGS},
7177
};
7278
}
7379
return {};
@@ -93,6 +99,9 @@ struct Main {
9399
}
94100

95101
auto process(auto const& path, auto const& lookup, auto const& provider, auto&& cb) const -> void {
102+
if (path.ends_with("/")) {
103+
return process_manual(path, lookup, cb);
104+
}
96105
if (path.find("projects/") != std::string::npos) {
97106
return process_rls(path, lookup, provider, cb);
98107
}
@@ -120,6 +129,7 @@ struct Main {
120129
auto process_rls(auto const& path, auto const& lookup, auto const& provider, auto&& cb) const -> void {
121130
try {
122131
rlib_trace("path: %s", path.c_str());
132+
rlib_assert(path.ends_with("releasemanifest"));
123133
auto data = read_file(path, lookup, provider);
124134
auto [realm, rest] = str_split(path, "projects/");
125135
auto rls = rads::RLS::read(data);
@@ -145,6 +155,7 @@ struct Main {
145155
auto process_sln(auto const& path, auto const& lookup, auto const& provider, auto&& cb) const -> void {
146156
try {
147157
rlib_trace("path: %s", path.c_str());
158+
rlib_assert(path.ends_with("solutionmanifest"));
148159
auto data = read_file(path, lookup, provider);
149160
auto [realm, rest] = str_split(path, "solutions/");
150161
auto sln = rads::SLN::read(data);
@@ -166,6 +177,19 @@ struct Main {
166177
error_stack().clear();
167178
}
168179
}
180+
181+
auto process_manual(auto path, auto const& lookup, auto&& cb) const -> void {
182+
rlib_trace("path: %s", path.c_str());
183+
std::transform(path.begin(), path.end(), path.begin(), ::tolower);
184+
for (auto const& [name, file] : lookup) {
185+
if (!name.starts_with(path)) {
186+
continue;
187+
}
188+
auto rfile = RMAN::File(*file);
189+
rfile.path = rfile.path.substr(path.size());
190+
cb(std::move(rfile));
191+
}
192+
}
169193
};
170194

171195
int main(int argc, char** argv) {

0 commit comments

Comments
 (0)