forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse SSH git requirements in poetry config. (pantsbuild#13344)
Reqs of the form [email protected]:foo/bar.git must be rewritten to ssh://[email protected]/foo/bar.git to become valid PEP 440 requirements. [ci skip-rust] [ci skip-build-wheels]
- Loading branch information
Showing
2 changed files
with
13 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import itertools | ||
import logging | ||
import os | ||
import urllib.parse | ||
from dataclasses import dataclass | ||
from pathlib import Path, PurePath | ||
from typing import Any, Iterable, Iterator, Mapping, Sequence, cast | ||
|
@@ -239,6 +240,10 @@ def handle_dict_attr( | |
|
||
git_lookup = attributes.get("git") | ||
if git_lookup is not None: | ||
# If no URL scheme (e.g., `{git = "[email protected]:foo/bar.git"}`) we assume ssh, | ||
# i.e., we convert to git+ssh://[email protected]/foo/bar.git. | ||
if not urllib.parse.urlsplit(git_lookup).scheme: | ||
git_lookup = f"ssh://{git_lookup.replace(':', '/', 1)}" | ||
rev_lookup = produce_match("#", attributes.get("rev")) | ||
branch_lookup = produce_match("@", attributes.get("branch")) | ||
tag_lookup = produce_match("@", attributes.get("tag")) | ||
|
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 |
---|---|---|
|
@@ -191,6 +191,14 @@ def assert_git(extra_opts: PyprojectAttr, suffix: str) -> None: | |
) | ||
|
||
|
||
def test_handle_git_ssh(empty_pyproject_toml: PyProjectToml) -> None: | ||
attr = PyprojectAttr({"git": "[email protected]:requests/requests.git"}) | ||
assert ( | ||
handle_dict_attr("requests", attr, empty_pyproject_toml) | ||
== "requests @ git+ssh://[email protected]/requests/requests.git" | ||
) | ||
|
||
|
||
def test_handle_path_arg(tmp_path: Path) -> None: | ||
build_root = tmp_path / "build_root" | ||
|
||
|