Reduce error potentials in type label parsing
This commit is contained in:
parent
b66e8c8d9c
commit
6d6fffcb4a
1 changed files with 10 additions and 14 deletions
|
|
@ -111,22 +111,18 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result<cra
|
|||
let ty_labels: Vec<_> = labels
|
||||
.iter()
|
||||
.filter_map(|l| l.name.as_deref())
|
||||
.filter(|l| l.starts_with("Type/"))
|
||||
.filter_map(|l| l.strip_prefix("Type/"))
|
||||
.collect();
|
||||
|
||||
if ty_labels.len() == 0 {
|
||||
let ty = match &ty_labels[..] {
|
||||
[ty] => ty.to_string(),
|
||||
[] => {
|
||||
anyhow::bail!("Issue #{issue_number} has no type label!");
|
||||
}
|
||||
if ty_labels.len() > 1 {
|
||||
[..] => {
|
||||
anyhow::bail!("Issue #{issue_number} has more than one type label!");
|
||||
}
|
||||
|
||||
let ty = ty_labels
|
||||
.first()
|
||||
.expect("TODO")
|
||||
.strip_prefix("Type/")
|
||||
.expect("TODO")
|
||||
.to_owned();
|
||||
};
|
||||
|
||||
let has_completed_label = labels
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue