From 65fe1e54f5279f0bbd0707266fcb67f0155d17b9 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 16 Dec 2024 21:31:27 -0600 Subject: [PATCH] Simplify self_link for build --- src/build.cpp | 9 +-------- src/launchpad.cpp | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/build.cpp b/src/build.cpp index db48afb..71ee646 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -51,14 +51,7 @@ void build::parse_json(const std::string& json_data) { {"can_be_cancelled", [this](const nlohmann::json& val) { can_be_cancelled = val.get(); }}, {"can_be_retried", [this](const nlohmann::json& val) { can_be_retried = val.get(); }}, {"title", [this](const nlohmann::json& val) { title = val.get(); }}, - {"self_link", [this](const nlohmann::json& val) { - self_link = val.get(); - std::regex rgx("/builds/(\\d+)"); - std::smatch match; - if (std::regex_search(self_link, match, rgx)) { - id = std::stol(match[1]); - } - }}, + {"self_link", [this](const nlohmann::json& val) { self_link = val.get(); }}, {"build_log_url", [this](const nlohmann::json& val) { build_log_url = val.get(); }}, {"upload_log_url", [this](const nlohmann::json& val) { upload_log_url = val.get(); }}, {"duration", [this](const nlohmann::json& val) { duration = val.get(); }}, diff --git a/src/launchpad.cpp b/src/launchpad.cpp index e13438d..1eaaaa8 100644 --- a/src/launchpad.cpp +++ b/src/launchpad.cpp @@ -221,8 +221,8 @@ std::string launchpad::build_full_url(const std::string& endpoint) const { std::optional launchpad::api_get(const std::string& endpoint, const std::map& params) const { std::string url = build_full_url(endpoint); if (url.empty()) { - std::cerr << "Internal error: please include the following info in a bug report:" << std::endl; if (!params.empty()) { + std::cerr << "Internal error: please include the following info in a bug report:" << std::endl; for (const auto& [key, value] : params) { std::cerr << url_encode(key) + "=" + url_encode(value) + "&"; } @@ -302,8 +302,8 @@ std::optional launchpad::api_post( const std::string& token_secret_override ) { if (endpoint.empty()) { - std::cerr << "Internal error: please include the following info in a bug report:" << std::endl; if (!params.empty()) { + std::cerr << "Internal error: please include the following info in a bug report:" << std::endl; for (const auto& [key, value] : params) { std::cerr << url_encode(key) + "=" + url_encode(value) + "&"; }