-
Notifications
You must be signed in to change notification settings - Fork 11
tests(config-variations): Git schemes in repo URLs #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tony
wants to merge
1
commit into
master
Choose a base branch
from
git-remote-url-scheme-pt2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -12,7 +12,7 @@ Detect VCS from `git`, `hg`, and `svn` URLs. | |
[ParserMatch(vcs='git', match=GitURL(...))] | ||
|
||
>>> registry.match('[email protected]:plasma/plasma-sdk.git', is_explicit=True) | ||
[] | ||
[ParserMatch(vcs='git', match=GitURL(...))] | ||
|
||
>>> registry.match('git+ssh://[email protected]:plasma/plasma-sdk.git') | ||
[ParserMatch(vcs='git', match=GitURL(...))] | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -68,6 +68,17 @@ def create_project( | |
) -> HgSync: ... | ||
|
||
|
||
@t.overload | ||
def create_project( | ||
*, | ||
url: str, | ||
path: StrPath, | ||
vcs: None = None, | ||
progress_callback: ProgressCallbackProtocol | None = None, | ||
**kwargs: dict[t.Any, t.Any], | ||
) -> GitSync | HgSync | SvnSync: ... | ||
|
||
|
||
def create_project( | ||
*, | ||
url: str, | ||
|
@@ -98,6 +109,15 @@ def create_project( | |
... path=tmp_path | ||
... ) | ||
|
||
>>> isinstance(r, GitSync) | ||
True | ||
|
||
It also supports unprefixed SSH-style Git URLs: | ||
|
||
>>> r = create_project( | ||
... url='[email protected]:tmux-python/tmuxp.git', | ||
... path=tmp_path | ||
... ) | ||
>>> isinstance(r, GitSync) | ||
True | ||
""" | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
""", | ||
re.VERBOSE, | ||
), | ||
is_explicit=True, | ||
), | ||
# ends with .git. Including ones starting with https:// | ||
# e.g. https://github.com/vcs-python/libvcs.git | ||
|
@@ -77,6 +78,7 @@ | |
re.VERBOSE, | ||
), | ||
defaults={"username": "git"}, | ||
is_explicit=True, | ||
), | ||
# SCP-style URLs, e.g. git@ | ||
] | ||
|
@@ -392,7 +394,7 @@ def is_valid(cls, url: str, is_explicit: bool | None = None) -> bool: | |
>>> GitBaseURL.is_valid( | ||
... url='[email protected]:vcs-python/libvcs.git', is_explicit=True | ||
... ) | ||
False | ||
True | ||
|
||
In this case, check :meth:`GitPipURL.is_valid` or :meth:`GitURL.is_valid`'s | ||
examples. | ||
|
@@ -764,7 +766,7 @@ def is_valid(cls, url: str, is_explicit: bool | None = None) -> bool: | |
>>> GitURL.is_valid( | ||
... url='[email protected]:vcs-python/libvcs.git', is_explicit=True | ||
... ) | ||
False | ||
True | ||
|
||
You could create a GitHub rule that consider github.com hostnames to be | ||
exclusively git: | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -70,3 +70,11 @@ def test_create_project( | |
else: | ||
repo = create_project(**repo_dict) | ||
assert isinstance(repo, repo_class) | ||
|
||
|
||
def test_create_project_infer_scp_git(tmp_path: pathlib.Path) -> None: | ||
"""Test create_project infers Git VCS for SCP-style URLs.""" | ||
url = "[email protected]:tmux-python/tmuxp.git" | ||
path = tmp_path / "tmuxp_repo" | ||
repo = create_project(url=url, path=path) | ||
assert isinstance(repo, GitSync) |
This file contains hidden or 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 |
---|---|---|
|
@@ -53,6 +53,8 @@ class DetectVCSFixture(t.NamedTuple): | |
"codecommit::ap-northeast-1://MyDemoRepo", | ||
"https://git-codecommit.us-east-1.amazonaws.com/v1/repos/test", | ||
"ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/test", | ||
# plain SCP-style Git URLs should be recognized explicitly | ||
"[email protected]:tmux-python/tmuxp.git", | ||
] | ||
], | ||
*[ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider using a single function signature with union types to reduce overload duplication and simplify the API while maintaining functionality
You can reduce overload duplication by declaring a single function signature that uses the union types for both the parameter and the return value. For example, remove the extra overload and use this unified signature:
This minimizes duplicate parameters and keeps the API clear while preserving all functionality.