MCPcopy Create free account
hub / github.com/arusahni/git-req / get_github_project_name

Function get_github_project_name

src/remotes/github.rs:101–107  ·  view source on GitHub ↗

Extract the project name from a Github origin URL

(origin: &str)

Source from the content-addressed store, hash-verified

99
100/// Extract the project name from a Github origin URL
101pub fn get_github_project_name(origin: &str) -> Option<String> {
102 trace!("Getting project name for: {}", origin);
103 let project_regex =
104 Regex::new(r"((http[s]?|ssh)://)?(\S+@)?[^:/]+[:/](?P<project>\S+?)(\.git)?$").unwrap();
105 let captures = project_regex.captures(origin)?.name("project")?;
106 Some(String::from(captures.as_str()))
107}
108
109#[cfg(test)]
110mod tests {

Calls

no outgoing calls