diff --git a/changelog/1221.feature.rst b/changelog/1221.feature.rst new file mode 100644 index 000000000..0b7b9c949 --- /dev/null +++ b/changelog/1221.feature.rst @@ -0,0 +1 @@ +have ``--skip-existing`` option work with newer versions of ``Nexus Repository OSS``. \ No newline at end of file diff --git a/tests/test_upload.py b/tests/test_upload.py index 249163999..59f01dc93 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( diff --git a/twine/commands/upload.py b/twine/commands/upload.py index 939e1dfab..beb81ab38 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -62,7 +62,13 @@ 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)