python-poetry / python-poetry/poetry
Poetry cannot add ssh urls from Azure Devops due to their URL
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: Windows 10 and Ubuntu 18.04
- Poetry version: 1.0.10
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/ShadowWolf/d96a51b85c484fc9cc1b5b9d9ca8247f
Issue
When running a command to add an SSH link to an Azure DevOps private repo, poetry cannot parse their SSH urls because they are very weird and have port-like identifiers that aren't ports in them.
For example something like this:
poetry add git+ssh://git@ssh.dev.azure.com:v3/[CompanyName]/[Project Name]/[Repo Name] -vvv
I also found it will fail if the path includes urlencoded elements, such as something like this:
poetry add git+ssh://git@ssh.dev.azure.com:v3/MyCompany/My%20Project/some-random-repo
~/poetry-test poetry add git+ssh://git@ssh.dev.azure.com:v3/[CompanyName]/[ProjectName]/[repo-name] -vvv
Using virtualenv: /home/bryanwolf/.cache/pypoetry/virtualenvs/poetry-test-VRaqNbsu-py3.8
[CalledProcessError]
Command '['git', '--git-dir', '/tmp/pypoetry-[repo-name]uas8kco8/.git', '--work-tree', '/tmp/pypoetry-git-[repo-name]uas8kco8', 'checkout', 'ssh.dev.azure.com:v3/[CompanyName]/[ProjectName]/[repo-name]']' returned non-zero exit status 1.
Traceback (most recent call last):
File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/home/bryanwolf/.poetry/lib/poetry/_vendor/py3.8/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/home/bryanwolf/.poetry/lib/poetry/console/commands/add.py", line 95, in handle
requirements = self._determine_requirements(
File "/home/bryanwolf/.poetry/lib/poetry/console/commands/init.py", line 293, in _determine_requirements
requires = self._parse_requirements(requires)
File "/home/bryanwolf/.poetry/lib/poetry/console/commands/init.py", line 380, in _parse_requirements
package = Provider.get_package_from_vcs(
File "/home/bryanwolf/.poetry/lib/poetry/puzzle/provider.py", line 207, in get_package_from_vcs
git.checkout(reference, tmp_dir)
File "/home/bryanwolf/.poetry/lib/poetry/vcs/git.py", line 217, in checkout
return self.run(*args)
File "/home/bryanwolf/.poetry/lib/poetry/vcs/git.py", line 284, in run
subprocess.check_output(["git"] + list(args), stderr=subprocess.STDOUT)
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/home/bryanwolf/.poetry/lib/poetry/utils/_compat.py", line 205, in run
raise CalledProcessError(
I think maybe this could be fixed by changing the pattern_formats by adding [v|V]? to port and % to path?
pattern_formats = {
"protocol": r"\w+",
"user": r"[a-zA-Z0-9_.-]+",
"resource": r"[a-zA-Z0-9_.-]+",
"port": r"[v|V]?\d+",
"path": r"[\w~.\-/\\%]+",
"name": r"[\w~.\-]+",
"rev": r"[^@#]+",
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in poetry/vcs/git.py, especially the URL pattern_formats shown in the issue, and reproduce the failure with the provided poetry add git+ssh command. Done means Azure DevOps SSH URLs, including encoded path elements and the v3 identifier, are parsed correctly and the repository checkout succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100