summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2021-04-24 07:55:19 -0400
committerDan Davison <dandavison7@gmail.com>2021-04-24 08:01:27 -0400
commitb1234ba4e8934cd133e6777b909c69608626bce7 (patch)
tree00d38509866b9e47aa674909ca483b80c72a321c
parent9b13f7bd77f74cbe5c54378eac065659b39849da (diff)
Implement tested feature: support HTTPs and SSH URLs
-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 {