summaryrefslogtreecommitdiff
path: root/src/other_tools/git_operations/git_config_settings.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-02-14 18:52:08 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-03-03 16:21:14 +0100
commit2f5654b7f81ac40d7764de59f0e2f343d9e76a0a (patch)
treeaa736f57fcbca81f6d7dd4ea94b9db90beeff6d5 /src/other_tools/git_operations/git_config_settings.hpp
parent91f33def73223721ad91f99040158f3ff54dffab (diff)
downloadjustbuild-2f5654b7f81ac40d7764de59f0e2f343d9e76a0a.tar.gz
Git: Add utility method for retrieving proxy information for libgit2 calls
Diffstat (limited to 'src/other_tools/git_operations/git_config_settings.hpp')
-rw-r--r--src/other_tools/git_operations/git_config_settings.hpp11
1 files changed, 11 insertions, 0 deletions
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<void(std::string const&, bool)>;
using anon_logger_ptr = std::shared_ptr<anon_logger_t>;
+/// \brief Contains the proxy URL if proxy is set, or nullopt if proxy unset.
+using ProxyInfo = std::optional<std::string>;
+
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<git_transport_certificate_check_cb>;
+/// \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<git_config> const& cfg,
+ std::string const& url,
+ anon_logger_ptr const& logger)
+ -> std::optional<ProxyInfo>;
+
} // namespace GitConfigSettings
#endif // INCLUDED_SRC_OTHER_TOOLS_GIT_OPERATIONS_GIT_CONFIG_SETTINGS_HPP