Allow plain strings for nixpkgs maintainer fields (#393)
* Allow plain strings for nixpkgs maintainer fields * apply fmt to changed files
This commit is contained in:
parent
29651d086b
commit
a4d8421312
|
@ -5,7 +5,9 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::data::import::NixOption;
|
use crate::data::import::NixOption;
|
||||||
use log::error;
|
use log::error;
|
||||||
use pandoc::{InputFormat, InputKind, OutputFormat, OutputKind, PandocOption, PandocOutput, PandocError};
|
use pandoc::{
|
||||||
|
InputFormat, InputKind, OutputFormat, OutputKind, PandocError, PandocOption, PandocOutput,
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -216,10 +218,13 @@ impl From<import::NixpkgsEntry> for Derivation {
|
||||||
.map(|l: &License| l.fullName.to_owned())
|
.map(|l: &License| l.fullName.to_owned())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let package_maintainers = package
|
let package_maintainers: Vec<Maintainer> = package
|
||||||
.meta
|
.meta
|
||||||
.maintainers
|
.maintainers
|
||||||
.map_or(Default::default(), Flatten::flatten);
|
.map_or(Default::default(), Flatten::flatten)
|
||||||
|
.into_iter()
|
||||||
|
.map(Into::into)
|
||||||
|
.collect();
|
||||||
|
|
||||||
let package_maintainers_set = package_maintainers
|
let package_maintainers_set = package_maintainers
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -316,7 +321,10 @@ impl From<import::NixOption> for Derivation {
|
||||||
PandocOption::LuaFilter(man_filter),
|
PandocOption::LuaFilter(man_filter),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let result = pandoc.execute().expect(&format!("Pandoc could not parse documentation of '{}'", name));
|
let result = pandoc.execute().expect(&format!(
|
||||||
|
"Pandoc could not parse documentation of '{}'",
|
||||||
|
name
|
||||||
|
));
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
PandocOutput::ToBuffer(description) => Some(description),
|
PandocOutput::ToBuffer(description) => Some(description),
|
||||||
|
@ -342,7 +350,33 @@ impl From<import::NixOption> for Derivation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Maintainer = import::Maintainer;
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Maintainer {
|
||||||
|
name: Option<String>,
|
||||||
|
github: Option<String>,
|
||||||
|
email: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<import::Maintainer> for Maintainer {
|
||||||
|
fn from(import: import::Maintainer) -> Self {
|
||||||
|
match import {
|
||||||
|
import::Maintainer::Full {
|
||||||
|
name,
|
||||||
|
github,
|
||||||
|
email,
|
||||||
|
} => Maintainer {
|
||||||
|
name,
|
||||||
|
github,
|
||||||
|
email,
|
||||||
|
},
|
||||||
|
import::Maintainer::Simple(name) => Maintainer {
|
||||||
|
name: Some(name),
|
||||||
|
github: None,
|
||||||
|
email: None,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<super::Flake> for Maintainer {
|
impl From<super::Flake> for Maintainer {
|
||||||
fn from(flake: super::Flake) -> Self {
|
fn from(flake: super::Flake) -> Self {
|
||||||
|
|
|
@ -98,10 +98,14 @@ pub struct Meta {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Maintainer {
|
#[serde(untagged)]
|
||||||
pub name: Option<String>,
|
pub enum Maintainer {
|
||||||
pub github: Option<String>,
|
Full {
|
||||||
pub email: Option<String>,
|
name: Option<String>,
|
||||||
|
github: Option<String>,
|
||||||
|
email: Option<String>,
|
||||||
|
},
|
||||||
|
Simple(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_enum! {
|
arg_enum! {
|
||||||
|
@ -267,7 +271,8 @@ mod tests {
|
||||||
"github": "AndersonTorres",
|
"github": "AndersonTorres",
|
||||||
"githubId": 5954806,
|
"githubId": 5954806,
|
||||||
"name": "Anderson Torres"
|
"name": "Anderson Torres"
|
||||||
}
|
},
|
||||||
|
"Fred Flintstone"
|
||||||
],
|
],
|
||||||
"name": "0verkill-unstable-2011-01-13",
|
"name": "0verkill-unstable-2011-01-13",
|
||||||
"outputsToInstall": [
|
"outputsToInstall": [
|
||||||
|
|
Loading…
Reference in a new issue