From 2f5654b7f81ac40d7764de59f0e2f343d9e76a0a Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 14 Feb 2023 18:52:08 +0100 Subject: Git: Add utility method for retrieving proxy information for libgit2 calls --- src/other_tools/git_operations/git_config_settings.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/other_tools/git_operations/git_config_settings.hpp') diff --git a/src/other_tools/git_operations/git_config_settings.hpp b/src/other_tools/git_operations/git_config_settings.hpp index 8aa412e8..afe8a73b 100644 --- a/src/other_tools/git_operations/git_config_settings.hpp +++ b/src/other_tools/git_operations/git_config_settings.hpp @@ -33,6 +33,9 @@ using git_transport_certificate_check_cb = auto (*)(git_cert*, using anon_logger_t = std::function; using anon_logger_ptr = std::shared_ptr; +/// \brief Contains the proxy URL if proxy is set, or nullopt if proxy unset. +using ProxyInfo = std::optional; + namespace GitConfigSettings { /// \brief Get a custom SSL certificate check callback to honor the existing @@ -44,6 +47,14 @@ namespace GitConfigSettings { anon_logger_ptr const& logger) -> std::optional; +/// \brief Get the remote proxy settings from envariables and the given git +/// config snapshot. Performs same checks and honors same settings as git. +/// Returns the proxy state and information, or nullopt if errors. +[[nodiscard]] auto GetProxySettings(std::shared_ptr const& cfg, + std::string const& url, + anon_logger_ptr const& logger) + -> std::optional; + } // namespace GitConfigSettings #endif // INCLUDED_SRC_OTHER_TOOLS_GIT_OPERATIONS_GIT_CONFIG_SETTINGS_HPP -- cgit v1.2.3