-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly recognise SCP-shorthand git remotes.
- Loading branch information
Showing
6 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
from pip._internal.vcs.versioncontrol import ( | ||
AuthInfo, | ||
RemoteNotFoundError, | ||
RemoteNotValidError, | ||
RevOptions, | ||
VersionControl, | ||
find_path_to_setup_from_repo_root, | ||
|
@@ -30,6 +31,18 @@ | |
|
||
HASH_REGEX = re.compile('^[a-fA-F0-9]{40}$') | ||
|
||
# SCP (Secure copy protocol) shorthand. e.g. '[email protected]:foo/bar.git' | ||
SCP_REGEX = re.compile(r"""^ | ||
# Optional user, e.g. 'git@' | ||
(\w+@)? | ||
# Server, e.g. 'github.com'. | ||
([^/:]+): | ||
# The server-side path. e.g. 'user/project.git'. Must start with an | ||
# alphanumeric character so as not to be confusable with a Windows paths | ||
# like 'C:/foo/bar' or 'C:\foo\bar'. | ||
(\w[^:]*) | ||
$""", re.VERBOSE) | ||
|
||
|
||
def looks_like_hash(sha): | ||
# type: (str) -> bool | ||
|
@@ -350,9 +363,12 @@ def _git_remote_to_pip_url(url): | |
# A local bare remote (git clone --mirror). | ||
# Needs a file:// prefix. | ||
return pathlib.PurePath(url).as_uri() | ||
# SCP shorthand. e.g. [email protected]:foo/bar.git | ||
# Should add an ssh:// prefix and replace the ':' with a '/'. | ||
return "ssh://" + url.replace(":", "/") | ||
scp_match = SCP_REGEX.match(url) | ||
if scp_match: | ||
# Add an ssh:// prefix and replace the ':' with a '/'. | ||
return scp_match.expand(r"ssh://\1\2/\3") | ||
# Otherwise, bail out. | ||
raise RemoteNotValidError(url) | ||
|
||
@classmethod | ||
def has_commit(cls, location, rev): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters