mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Add ability to set release name from API
This commit is contained in:
parent
2d7845209f
commit
40edbc7a3b
@ -325,15 +325,19 @@ def create_release(token, package):
|
||||
else:
|
||||
data = request.form
|
||||
|
||||
if "title" not in data:
|
||||
error(400, "Title is required in the POST data")
|
||||
if not ("title" in data or "name" in data):
|
||||
error(400, "name is required in the POST data")
|
||||
|
||||
name = data.get("name")
|
||||
title = data.get("title") or name
|
||||
name = name or title
|
||||
|
||||
if data.get("method") == "git":
|
||||
for option in ["method", "ref"]:
|
||||
if option not in data:
|
||||
error(400, option + " is required in the POST data")
|
||||
|
||||
return api_create_vcs_release(token, package, data["title"], data["title"], data.get("release_notes"), data["ref"])
|
||||
return api_create_vcs_release(token, package, name, title, data.get("release_notes"), data["ref"])
|
||||
|
||||
elif request.files:
|
||||
file = request.files.get("file")
|
||||
@ -342,7 +346,7 @@ def create_release(token, package):
|
||||
|
||||
commit_hash = data.get("commit")
|
||||
|
||||
return api_create_zip_release(token, package, data["title"], data["title"], data.get("release_notes"), file, None, None, "API", commit_hash)
|
||||
return api_create_zip_release(token, package, name, title, data.get("release_notes"), file, None, None, "API", commit_hash)
|
||||
|
||||
else:
|
||||
error(400, "Unknown release-creation method. Specify the method or provide a file.")
|
||||
|
@ -268,7 +268,7 @@ Examples:
|
||||
# Create release from Git
|
||||
curl -X POST https://content.minetest.net/api/packages/username/name/releases/new/ \
|
||||
-H "Authorization: Bearer YOURTOKEN" -H "Content-Type: application/json" \
|
||||
-d '{ "method": "git", "title": "My Release", "ref": "master" }'
|
||||
-d '{ "method": "git", "name": "1.2.3", "title": "My Release", "ref": "master", "release_notes": "some\nrelease\nnotes\n" }'
|
||||
|
||||
# Create release from zip upload
|
||||
curl -X POST https://content.minetest.net/api/packages/username/name/releases/new/ \
|
||||
|
@ -25,7 +25,7 @@ from app.logic.LogicError import LogicError
|
||||
from app.logic.uploads import upload_file
|
||||
from app.models import PackageRelease, db, Permission, User, Package, MinetestRelease
|
||||
from app.tasks.importtasks import make_vcs_release, check_zip_release
|
||||
from app.utils import AuditSeverity, add_audit_log, nonempty_or_none
|
||||
from app.utils import AuditSeverity, add_audit_log, nonempty_or_none, normalize_line_endings
|
||||
|
||||
|
||||
def check_can_create_release(user: User, package: Package):
|
||||
@ -46,7 +46,7 @@ def do_create_vcs_release(user: User, package: Package, name: str, title: Option
|
||||
rel.package = package
|
||||
rel.name = name
|
||||
rel.title = title or name
|
||||
rel.release_notes = release_notes
|
||||
rel.release_notes = normalize_line_endings(release_notes)
|
||||
rel.url = ""
|
||||
rel.task_id = uuid()
|
||||
rel.min_rel = min_v
|
||||
@ -82,7 +82,7 @@ def do_create_zip_release(user: User, package: Package, name: str, title: Option
|
||||
rel.package = package
|
||||
rel.name = name
|
||||
rel.title = title or name
|
||||
rel.release_notes = release_notes
|
||||
rel.release_notes = normalize_line_endings(release_notes)
|
||||
rel.url = uploaded_url
|
||||
rel.task_id = uuid()
|
||||
rel.commit_hash = commit_hash
|
||||
|
Loading…
Reference in New Issue
Block a user