summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/git_config/git_config_entry.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/git_config/git_config_entry.rs b/src/git_config/git_config_entry.rs
index f8c63c69..2dcb8783 100644
--- a/src/git_config/git_config_entry.rs
+++ b/src/git_config/git_config_entry.rs
@@ -20,8 +20,20 @@ pub enum GitRemoteRepo {
}
lazy_static! {
- static ref GITHUB_REMOTE_URL: Regex =
- Regex::new(r"github\.com[:/]([^/]+)/(.+?)(?:\.git)?$").unwrap();
+ static ref GITHUB_REMOTE_URL: Regex = Regex::new(
+ r"(?x)
+ ^
+ (?:https://|git@) # Support both HTTPS and SSH URLs
+ github\.com
+ [:/] # This separator differs between SSH and HTTPS URLs
+ ([^/]+) # Capture the user/org name
+ /
+ (.+?) # Capture the repo name (lazy to avoid consuming '.git' if present)
+ (?:\.git)? # Non-capturing group to consume '.git' if present
+ $
+ "
+ )
+ .unwrap();
}
impl FromStr for GitRemoteRepo {