From 618aa5f38479ba245020cbcd9cd2f4ed6ea005bf Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Fri, 25 Oct 2024 19:44:36 -0400 Subject: [PATCH] Add failing test that shows when vcs is intalled by the commit hash the ref is null --- pipenv/cli/command.py | 2 +- pipenv/resolver.py | 3 +-- tests/integration/test_install_vcs.py | 28 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index acfb96567a..29fd85ed65 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -296,7 +296,7 @@ def uninstall(ctx, state, all_dev=False, all=False, **kwargs): all=all, pre=pre, pypi_mirror=state.pypi_mirror, - pipfile_categories=state.installstate.categories, + categories=state.installstate.categories, ctx=ctx, ) if retcode: diff --git a/pipenv/resolver.py b/pipenv/resolver.py index c478f868a0..0236bd195e 100644 --- a/pipenv/resolver.py +++ b/pipenv/resolver.py @@ -4,7 +4,6 @@ import os import sys from dataclasses import dataclass, field -from functools import cached_property from pathlib import Path from typing import Any, Dict, List, Optional, Set @@ -228,7 +227,7 @@ def _get_pipfile_content(self) -> Dict[str, Any]: return tomlkit_value_to_python(self.project.parsed_pipfile.get(self.category, {})) - @cached_property + @property def get_cleaned_dict(self) -> Dict[str, Any]: """Create a cleaned dictionary representation of the entry.""" cleaned = { diff --git a/tests/integration/test_install_vcs.py b/tests/integration/test_install_vcs.py index 390e1782b4..b0d587b4ac 100644 --- a/tests/integration/test_install_vcs.py +++ b/tests/integration/test_install_vcs.py @@ -1,4 +1,5 @@ import os +from pathlib import Path import pytest @@ -43,3 +44,30 @@ def test_install_github_vcs_with_credentials(pipenv_instance_pypi, use_credentia # Verify that the package is installed and usable c = p.pipenv("run python -c \"import dataclass_factory\"") assert c.returncode == 0, f"Failed to import library: {c.stderr}" + + +@pytest.mark.vcs +@pytest.mark.urls +@pytest.mark.install +@pytest.mark.needs_internet +def test_install_vcs_ref_by_commit_hash(pipenv_instance_private_pypi): + with pipenv_instance_private_pypi() as p: + c = p.pipenv("install -e git+https://github.com/benjaminp/six.git@5efb522b0647f7467248273ec1b893d06b984a59@#egg=six") + assert c.returncode == 0 + assert "six" in p.pipfile["packages"] + assert "six" in p.lockfile["default"] + assert ( + p.lockfile["default"]["six"]["ref"] + == "5efb522b0647f7467248273ec1b893d06b984a59" + ) + pipfile = Path(p.pipfile_path) + new_content = pipfile.read_text().replace("5efb522b0647f7467248273ec1b893d06b984a59", "15e31431af97e5e64b80af0a3f598d382bcdd49a") + pipfile.write_text(new_content) + c = p.pipenv("lock") + assert c.returncode == 0 + assert ( + p.lockfile["default"]["six"]["ref"] + == "15e31431af97e5e64b80af0a3f598d382bcdd49a" + ) + assert "six" in p.pipfile["packages"] + assert "six" in p.lockfile["default"]