From 05c096b37c2f546d3f68d69996d64e3204ec4fc4 Mon Sep 17 00:00:00 2001 From: Jacques Fournier Date: Fri, 24 Jan 2025 17:01:06 +0100 Subject: [PATCH] feat: address comments --- tests/test_upload.py | 24 +++++++++++++----------- twine/commands/upload.py | 11 +++++++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/test_upload.py b/tests/test_upload.py index 91c7dc8e..7d0bfd7e 100644 --- a/tests/test_upload.py +++ b/tests/test_upload.py @@ -466,7 +466,7 @@ def test_prints_skip_message_for_response( "http://www.foo.bar" ), ), - id="nexus", + id="nexus_old_case1", ), pytest.param( dict( @@ -477,6 +477,18 @@ def test_prints_skip_message_for_response( "\n" ), ), + id="nexus_old_case2", + ), + pytest.param( + dict( + status_code=400, + text=( + '
\n' + " pypi-local:twine/1.5.0/twine-1.5.0-py2.py3-none-any.whl" + " cannot be updated" + "
\n" + ), + ), id="nexus_new", ), pytest.param( @@ -520,16 +532,6 @@ def test_prints_skip_message_for_response( ), id="gitlab_enterprise", ), - pytest.param( - dict( - status_code=400, - text=( - "pypi-local:twine/1.5.0/twine-1.5.0-py2.py3-none-any.whl" - " cannot be updated" - ), - ), - id="sonatype_nexus", - ), ], ) def test_skip_existing_skips_files_on_repository(response_kwargs): diff --git a/twine/commands/upload.py b/twine/commands/upload.py index b5de4f47..beb81ab3 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -62,14 +62,17 @@ def skip_upload( # PyPI / TestPyPI / GCP Artifact Registry or (status == 400 and any("already exist" in x for x in [reason, text])) # Nexus Repository OSS (https://www.sonatype.com/nexus-repository-oss) - or (status == 400 and any("updating asset" in x for x in [reason, text])) + or ( + status == 400 + and ( + any("updating asset" in x for x in [reason, text]) + or ("cannot be updated" in text) + ) + ) # Artifactory (https://jfrog.com/artifactory/) or (status == 403 and "overwrite artifact" in text) # Gitlab Enterprise Edition (https://about.gitlab.com) or (status == 400 and "already been taken" in text) - # Sonatype Nexus Repository - # (https://help.sonatype.com/en/pypi-repositories.html) - or (status == 400 and "cannot be updated" in text) )