Skip to content

Commit d2d989c

Browse files
authored
Fix --skip-existing for twine (#3522)
1 parent 23633d5 commit d2d989c

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

tests/unit/forklift/test_legacy.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,10 +1835,7 @@ def test_upload_fails_with_existing_filename_diff_content(self,
18351835
pretend.call('help', _anchor='file-name-reuse')
18361836
]
18371837
assert resp.status_code == 400
1838-
assert resp.status == (
1839-
"400 The filename or contents already exist. "
1840-
"See /the/help/url/"
1841-
)
1838+
assert resp.status == "400 File already exists. See /the/help/url/"
18421839

18431840
def test_upload_fails_with_diff_filename_same_blake2(self,
18441841
pyramid_config,
@@ -1897,10 +1894,7 @@ def test_upload_fails_with_diff_filename_same_blake2(self,
18971894
pretend.call('help', _anchor='file-name-reuse')
18981895
]
18991896
assert resp.status_code == 400
1900-
assert resp.status == (
1901-
"400 The filename or contents already exist. "
1902-
"See /the/help/url/"
1903-
)
1897+
assert resp.status == "400 File already exists. See /the/help/url/"
19041898

19051899
def test_upload_fails_with_wrong_filename(self, pyramid_config,
19061900
db_request):

warehouse/forklift/legacy.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,11 +1097,16 @@ def file_upload(request):
10971097
return Response()
10981098
elif is_duplicate is not None:
10991099
raise _exc_with_message(
1100-
HTTPBadRequest, "The filename or contents already exist. "
1101-
"See " +
1102-
request.route_url(
1103-
'help', _anchor='file-name-reuse'
1104-
)
1100+
HTTPBadRequest,
1101+
# Note: Changing this error message to something that doesn't
1102+
# start with "File already exists" will break the
1103+
# --skip-existing functionality in twine
1104+
# ref: https://github.com/pypa/warehouse/issues/3482
1105+
# ref: https://github.com/pypa/twine/issues/332
1106+
"File already exists. See " +
1107+
request.route_url(
1108+
'help', _anchor='file-name-reuse'
1109+
)
11051110
)
11061111

11071112
# Check to see if the file that was uploaded exists in our filename log

0 commit comments

Comments
 (0)