Skip to content

Commit

Permalink
feat: support ssh url for github repos (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccaulonque authored Apr 10, 2024
1 parent 75ca1c2 commit 64a2274
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ pub fn get_current_repo() -> Result<String, Error> {
for line in git_config.lines() {
if line.contains("url = ") {
let url = line.split("url = ").collect::<Vec<&str>>()[1];
let repo = url.replace("https://github.com/", "").replace(".git", "");
let repo = if url.starts_with("https://github.com/") {
url.replace("https://github.com/", "").replace(".git", "")
} else if url.starts_with("git@github.com:") {
url.replace("git@github.com:", "").replace(".git", "")
} else {
return Err(Error::new(
ErrorKind::Other,
"Unsupported repo URL format.".to_string(),
));
};

return Ok(repo);
}
}
Expand Down

0 comments on commit 64a2274

Please sign in to comment.