Skip to content

Commit

Permalink
feat: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Fournier committed Jan 24, 2025
1 parent 4df1dc8 commit 05c096b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
24 changes: 13 additions & 11 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def test_prints_skip_message_for_response(
"http://www.foo.bar"
),
),
id="nexus",
id="nexus_old_case1",
),
pytest.param(
dict(
Expand All @@ -477,6 +477,18 @@ def test_prints_skip_message_for_response(
"</div>\n"
),
),
id="nexus_old_case2",
),
pytest.param(
dict(
status_code=400,
text=(
'<div class="content-section">\n'
" pypi-local:twine/1.5.0/twine-1.5.0-py2.py3-none-any.whl"
" cannot be updated"
"</div>\n"
),
),
id="nexus_new",
),
pytest.param(
Expand Down Expand Up @@ -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):
Expand Down
11 changes: 7 additions & 4 deletions twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)


Expand Down

0 comments on commit 05c096b

Please sign in to comment.