summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Paarmann <github@s-paarmann.de>2021-07-26 15:37:45 +0200
committerGitHub <noreply@github.com>2021-07-26 14:37:45 +0100
commitc2dc651678843c18287e7dab6e189b1f8eb4e123 (patch)
tree36c101966812f14defe9954e24e2ecaae128477e
parent63fdebbf68878fa52fe178f0e5d2a89478345878 (diff)
Recognize GitHub SSH remote URLs that don't start with `git@` for hyperlinks (#668)
Closes #667. SSH remote URLs are usually formatted as `git@github.com:user/repo` but certain setups can allow using just `github.com:user/repo`, see issue #667 for an example. This modifies the regex used to detect a GitHub remote for hyperlink generation to also allow the latter form.
-rw-r--r--src/git_config/git_config_entry.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/git_config/git_config_entry.rs b/src/git_config/git_config_entry.rs
index 2dcb8783..81787181 100644
--- a/src/git_config/git_config_entry.rs
+++ b/src/git_config/git_config_entry.rs
@@ -23,7 +23,7 @@ lazy_static! {
static ref GITHUB_REMOTE_URL: Regex = Regex::new(
r"(?x)
^
- (?:https://|git@) # Support both HTTPS and SSH URLs
+ (?:https://|git@)? # Support both HTTPS and SSH URLs, SSH URLs optionally omitting the git@
github\.com
[:/] # This separator differs between SSH and HTTPS URLs
([^/]+) # Capture the user/org name
@@ -62,6 +62,8 @@ mod tests {
"https://github.com/dandavison/delta",
"git@github.com:dandavison/delta.git",
"git@github.com:dandavison/delta",
+ "github.com:dandavison/delta.git",
+ "github.com:dandavison/delta",
];
for url in urls {
let parsed = GitRemoteRepo::from_str(url);