diff options
| author | Dan Engelbrecht <[email protected]> | 2025-06-17 13:24:29 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-06-17 13:24:29 +0200 |
| commit | ecd3df960ea77df179f9a6fb991536f3f5e6b6d4 (patch) | |
| tree | d17336cf23cdc98e2682bff51390541252088367 | |
| parent | graceful wait in parallelwork destructor (#438) (diff) | |
| download | zen-ecd3df960ea77df179f9a6fb991536f3f5e6b6d4.tar.xz zen-ecd3df960ea77df179f9a6fb991536f3f5e6b6d4.zip | |
accept Cloud urls without the api/v2/builds/ part (#439)
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zen/cmds/builds_cmd.cpp | 70 |
2 files changed, 46 insertions, 25 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b27c5093..6d6180ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - `UE_ZEN_SENTRY_ALLOWPERSONALINFO`: `--sentry-allow-personal-info` - `UE_ZEN_SENTRY_DSN`: `--sentry-dsn` - `UE_ZEN_SENTRY_ENVIRONMENT`: `--sentry-environment` +- Improvement: `zen build --cloud-url` option now accepts URLs without the `api/v2/builds/` part in urls - Bugfix: Range requests for build blobs that reached end of blob now works correctly - Bugfix: Gracefully handle a malformed response when querying list of blocks diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp index 706fdf9ba..be640fe31 100644 --- a/src/zen/cmds/builds_cmd.cpp +++ b/src/zen/cmds/builds_cmd.cpp @@ -806,6 +806,50 @@ namespace { return CleanWipe; } + bool ParseCloudUrl(std::string_view InUrl, + std::string& OutHost, + std::string& OutNamespace, + std::string& OutBucket, + std::string& OutBuildId) + { + std::string Url(RemoveQuotes(InUrl)); + const std::string_view ExtendedApiString = "api/v2/builds/"; + if (auto ApiString = ToLower(Url).find(ExtendedApiString); ApiString != std::string::npos) + { + Url.erase(ApiString, ExtendedApiString.length()); + } + + const std::string ArtifactURLRegExString = R"((http[s]?:\/\/.*?)\/(.*?)\/(.*?)\/(.*))"; + const std::regex ArtifactURLRegEx(ArtifactURLRegExString, std::regex::ECMAScript | std::regex::icase); + std::match_results<std::string_view::const_iterator> MatchResults; + std::string_view UrlToParse(Url); + if (regex_match(begin(UrlToParse), end(UrlToParse), MatchResults, ArtifactURLRegEx) && MatchResults.size() == 5) + { + auto GetMatch = [&MatchResults](uint32_t Index) -> std::string_view { + ZEN_ASSERT(Index < MatchResults.size()); + + const auto& Match = MatchResults[Index]; + + return std::string_view(&*Match.first, Match.second - Match.first); + }; + + const std::string_view Host = GetMatch(1); + const std::string_view Namespace = GetMatch(2); + const std::string_view Bucket = GetMatch(3); + const std::string_view BuildId = GetMatch(4); + + OutHost = Host; + OutNamespace = Namespace; + OutBucket = Bucket; + OutBuildId = BuildId; + return true; + } + else + { + return false; + } + } + std::string ReadAccessTokenFromFile(const std::filesystem::path& Path) { if (!IsFile(Path)) @@ -10083,31 +10127,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { throw zen::OptionParseException(fmt::format("buildid is not compatible with the url option\n{}", SubOption->help())); } - const std::string ArtifactURLRegExString = R"((.*?:\/\/.*?)\/api\/v2\/builds\/(.*?)\/(.*?)\/(.*))"; - const std::regex ArtifactURLRegEx(ArtifactURLRegExString, std::regex::ECMAScript); - std::match_results<std::string_view::const_iterator> MatchResults; - const std::string_view Url(RemoveQuotes(m_Url)); - if (regex_match(begin(Url), end(Url), MatchResults, ArtifactURLRegEx) && MatchResults.size() == 5) - { - auto GetMatch = [&MatchResults](uint32_t Index) -> std::string_view { - ZEN_ASSERT(Index < MatchResults.size()); - - const auto& Match = MatchResults[Index]; - - return std::string_view(&*Match.first, Match.second - Match.first); - }; - - const std::string_view Host = GetMatch(1); - const std::string_view Namespace = GetMatch(2); - const std::string_view Bucket = GetMatch(3); - const std::string_view BuildId = GetMatch(4); - - m_Host = Host; - m_Namespace = Namespace; - m_Bucket = Bucket; - m_BuildId = BuildId; - } - else + if (!ParseCloudUrl(m_Url, m_Host, m_Namespace, m_Bucket, m_BuildId)) { throw zen::OptionParseException(fmt::format("url does not match the Cloud Artifact URL format\n{}", SubOption->help())); } |