You've already forked AstralRinth
forked from didirus/AstralRinth
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:
@@ -121,8 +121,24 @@ impl From<QueryProject> for Project {
|
||||
None
|
||||
},
|
||||
license: License {
|
||||
id: data.license_id,
|
||||
name: data.license_name,
|
||||
id: m.license.clone(),
|
||||
name: match spdx::Expression::parse(&*m.license) {
|
||||
Ok(spdx_expr) => {
|
||||
let mut vec: Vec<&str> = Vec::new();
|
||||
for node in spdx_expr.iter() {
|
||||
if let spdx::expression::ExprNode::Req(req) = node {
|
||||
if let Some(id) = req.req.license.id() {
|
||||
vec.push(id.full_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// spdx crate returns AND/OR operations in postfix order
|
||||
// and it would be a lot more effort to make it actually in order
|
||||
// so let's just ignore that and make them comma-separated
|
||||
vec.join(", ")
|
||||
}
|
||||
Err(_) => "".to_string(),
|
||||
},
|
||||
url: m.license_url,
|
||||
},
|
||||
client_side: data.client_side,
|
||||
@@ -215,6 +231,8 @@ impl SideType {
|
||||
}
|
||||
}
|
||||
|
||||
pub const DEFAULT_LICENSE_ID: &str = "LicenseRef-All-Rights-Reserved";
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct License {
|
||||
pub id: String,
|
||||
|
||||
Reference in New Issue
Block a user