Skip to content

Commit 72eabf6

Browse files
committed
Fix #499: allow license.md/changelog.md/readme.md files
1 parent 119d91d commit 72eabf6

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

bananas_api/new_upload/session_validation.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ def validate_license(session):
3131
session["errors"].append("License is not yet set for this package.")
3232
elif session["license"] == License.CUSTOM:
3333
for file_info in session["files"]:
34-
if file_info["filename"] == "license.txt":
34+
if file_info["filename"] in ("license.txt", "license.md"):
3535
break
3636
else:
37-
session["errors"].append("License is set to custom, but no license.txt is uploaded.")
37+
session["errors"].append("License is set to custom, but no 'license.txt' or 'license.md' is uploaded.")
3838
else:
3939
for file_info in session["files"]:
40-
if file_info["filename"] == "license.txt":
40+
if file_info["filename"] in ("license.txt", "license.md"):
4141
session["errors"].append(
42-
f"License is set to {session['license'].value}; this does not require uploading 'license.txt'."
42+
f"License is set to {session['license'].value}; "
43+
"this does not require uploading 'license.txt' or 'license.md'."
4344
)
4445

4546

bananas_api/new_upload/validate.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@
9797

9898
# readme.txt and changelog.txt can have translations. This can be with the
9999
# first part of the ISO code, or with the full. For example:
100-
# readme.txt, readme_nl.txt, readme_nl_NL.txt
100+
# readme.txt, readme_nl.txt, readme_nl_NL.txt, readme.md
101101
# All other variantions are not valid.
102-
txt_regexp = re.compile(r"(readme|changelog)(_[a-z]{2}(_[A-Z]{2})?)?\.txt$")
102+
txt_regexp = re.compile(r"(readme|changelog)(_[a-z]{2}(_[A-Z]{2})?)?\.(txt|md)$")
103103

104104

105105
def _validate_textfile_encoding(fp):
@@ -111,14 +111,14 @@ def _validate_textfile_encoding(fp):
111111

112112
def _read_object(filename, fp):
113113
lfilename = filename.lower()
114-
if lfilename.endswith(".txt"):
115-
if filename == "license.txt":
116-
_validate_textfile_encoding(fp)
117-
return None
118-
elif txt_regexp.match(filename):
119-
_validate_textfile_encoding(fp)
120-
return None
121-
elif filename.startswith("lang/"):
114+
if filename in ("license.txt", "license.md"):
115+
_validate_textfile_encoding(fp)
116+
return None
117+
elif txt_regexp.match(filename):
118+
_validate_textfile_encoding(fp)
119+
return None
120+
elif lfilename.endswith(".txt"):
121+
if filename.startswith("lang/"):
122122
_validate_textfile_encoding(fp)
123123
return None
124124
else:

regression/100_success_base_sounds.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ steps:
44
- file-upload: nosound.obs
55
- file-upload: nosound.cat
66
- file-upload: license.txt
7+
name: license.md
78
- file-upload: readme.txt
8-
name: readme_nl.txt
9+
name: readme_nl.md
910
- file-upload: changelog.txt
10-
name: changelog_nl.txt
11+
name: changelog_nl.md
1112
- api: new-package/update
1213
name: "test"
1314
version: "v1"

regression/921_missing_custom_license.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ steps:
66
version: "test"
77
license: "Custom"
88
- api: new-package/publish
9-
error: "License is set to custom, but no license.txt is uploaded."
9+
error: "License is set to custom, but no 'license.txt' or 'license.md' is uploaded."

regression/923_custom_and_defined_license.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ steps:
77
version: "test"
88
license: "GPL v2"
99
- api: new-package/publish
10-
error: "License is set to GPL v2; this does not require uploading 'license.txt'."
10+
error: "License is set to GPL v2; this does not require uploading 'license.txt' or 'license.md'."

0 commit comments

Comments
 (0)