flams_git/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3#[cfg(feature = "gitlab")]
4pub mod gl;
5#[cfg(feature = "git2")]
6pub mod repos;
7
8#[cfg(any(feature = "git2", feature = "gitlab"))]
9pub use git_url_parse::GitUrl;
10
11
12#[cfg(any(feature = "git2", feature = "gitlab"))]
13pub(crate) static REMOTE_SPAN: std::sync::LazyLock<tracing::Span> =
14 std::sync::LazyLock::new(|| tracing::info_span!(target:"git",parent:None,"git"));
15
16#[cfg(any(feature = "git2", feature = "gitlab"))]
17pub trait GitUrlExt {
18 #[must_use]
19 fn into_https(self) -> Self;
20}
21#[cfg(any(feature = "git2", feature = "gitlab"))]
22impl GitUrlExt for GitUrl {
23 fn into_https(mut self) -> Self {
24 self = self.trim_auth();
25 self.scheme = git_url_parse::Scheme::Https;
26 self.scheme_prefix = true;
27 if !self.path.starts_with('/') {
28 self.path = format!("/{}", self.path);
29 }
30 self
31 }
32}