Move to SPDX licenses (#449)

* Move to SPDX licenses

Found a way to do this without breaking API compat, so here it is, instead of waiting for v3

Resolves MOD-129
Resolves #396

* License URL updates

* what was I thinking

* Do a thing

* Add open source filter

* Remove dead imports

* Borrow

* Update 20220910132835_spdx-licenses.sql

* Add license text route

* Update migration

* Address comments
This commit is contained in:
triphora
2022-11-29 23:53:24 -05:00
committed by GitHub
parent 34688852a4
commit 820519b4f7
15 changed files with 748 additions and 1007 deletions

View File

@@ -857,12 +857,18 @@ pub async fn project_edit(
));
}
let license_id = database::models::categories::License::get_id(
license,
&mut *transaction,
)
.await?
.expect("No database entry found for license");
let mut license = license.clone();
if license.to_lowercase() == "arr" {
license = models::projects::DEFAULT_LICENSE_ID.to_string();
}
spdx::Expression::parse(&*license).map_err(|err| {
ApiError::InvalidInput(format!(
"Invalid SPDX license identifier: {}",
err
))
})?;
sqlx::query!(
"
@@ -870,7 +876,7 @@ pub async fn project_edit(
SET license = $1
WHERE (id = $2)
",
license_id as database::models::LicenseId,
license,
id as database::models::ids::ProjectId,
)
.execute(&mut *transaction)