MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / match_git_ssh_url

Function match_git_ssh_url

crates/cargo-lambda-new/src/template.rs:309–340  ·  view source on GitHub ↗
(value: &str)

Source from the content-addressed store, hash-verified

307}
308
309fn match_git_ssh_url(value: &str) -> Option<GitRepo> {
310 let ssh_regex = regex::Regex::new(
311 r"ssh://(?P<host>[a-zA-Z0-9.-]+)/(?P<repo>[a-zA-Z0-9][a-zA-Z0-9_-]+/[a-zA-Z0-9][a-zA-Z0-9_-]+)(\.git)?$",
312 )
313 .into_diagnostic()
314 .expect("invalid SSH regex");
315
316 let git_regex = regex::Regex::new(
317 r"git@(?P<host>[a-zA-Z0-9.-]+):(?P<repo>[a-zA-Z0-9][a-zA-Z0-9_-]+/[a-zA-Z0-9][a-zA-Z0-9_-]+)(\.git)?$",
318 )
319 .into_diagnostic()
320 .expect("invalid Git SSH regex");
321
322 let (auth_user, caps) = match ssh_regex.captures(value) {
323 None => match git_regex.captures(value) {
324 None => return None,
325 Some(caps) => (Some("git".into()), caps),
326 },
327 Some(caps) => (None, caps),
328 };
329
330 let host = caps.name("host")?;
331 let repo = caps.name("repo")?;
332
333 Some(GitRepo {
334 host: host.as_str().into(),
335 repo: repo.as_str().into(),
336 protocol: GitProtocol::Ssh,
337 auth_user,
338 ..Default::default()
339 })
340}
341
342#[tracing::instrument(target = "cargo_lambda")]
343fn clone_git_repo(repo: &GitRepo, path: &Path) -> Result<()> {

Callers 2

try_fromMethod · 0.85
test_match_git_ssh_urlFunction · 0.85

Calls 2

newFunction · 0.85
as_strMethod · 0.80

Tested by 1

test_match_git_ssh_urlFunction · 0.68