Skip to content

Commit 7569838

Browse files
authored
Handle UV bug (#1388)
1 parent 62ed6c3 commit 7569838

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

backend/src/hatchling/dep/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def dependency_in_sync(
110110
else:
111111
return False
112112
result = subprocess.run(vcs_cmd, capture_output=True, text=True) # noqa: PLW1510
113-
if result.returncode:
113+
if result.returncode or not result.stdout.strip():
114114
return False
115115
latest_commit_id, *_ = result.stdout.split()
116116
return commit_id == latest_commit_id

tests/backend/dep/test_core.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_extra_met(platform, uv_on_path):
7575

7676
@pytest.mark.requires_internet
7777
@pytest.mark.requires_git
78-
def test_dependency_git(platform):
78+
def test_dependency_git_pip(platform):
7979
with TempVirtualEnv(sys.executable, platform) as venv:
8080
platform.run_command(
8181
['pip', 'install', 'requests@git+https://github.com/psf/requests'], check=True, capture_output=True
@@ -85,14 +85,40 @@ def test_dependency_git(platform):
8585

8686
@pytest.mark.requires_internet
8787
@pytest.mark.requires_git
88-
def test_dependency_git_revision(platform):
88+
def test_dependency_git_uv(platform, uv_on_path):
89+
with TempUVVirtualEnv(sys.executable, platform) as venv:
90+
platform.run_command(
91+
[uv_on_path, 'pip', 'install', 'requests@git+https://github.com/psf/requests'],
92+
check=True,
93+
capture_output=True,
94+
)
95+
assert not dependencies_in_sync([Requirement('requests@git+https://github.com/psf/requests')], venv.sys_path)
96+
97+
98+
@pytest.mark.requires_internet
99+
@pytest.mark.requires_git
100+
def test_dependency_git_revision_pip(platform):
89101
with TempVirtualEnv(sys.executable, platform) as venv:
90102
platform.run_command(
91103
['pip', 'install', 'requests@git+https://github.com/psf/requests@main'], check=True, capture_output=True
92104
)
93105
assert dependencies_in_sync([Requirement('requests@git+https://github.com/psf/requests@main')], venv.sys_path)
94106

95107

108+
@pytest.mark.requires_internet
109+
@pytest.mark.requires_git
110+
def test_dependency_git_revision_uv(platform, uv_on_path):
111+
with TempUVVirtualEnv(sys.executable, platform) as venv:
112+
platform.run_command(
113+
[uv_on_path, 'pip', 'install', 'requests@git+https://github.com/psf/requests@main'],
114+
check=True,
115+
capture_output=True,
116+
)
117+
assert not dependencies_in_sync(
118+
[Requirement('requests@git+https://github.com/psf/requests@main')], venv.sys_path
119+
)
120+
121+
96122
@pytest.mark.requires_internet
97123
@pytest.mark.requires_git
98124
def test_dependency_git_commit(platform, uv_on_path):

0 commit comments

Comments
 (0)