forked from the-distro/ofborg
labeling: make log messages one-line
This commit is contained in:
parent
8e6f78607b
commit
3bc29be475
|
@ -518,36 +518,43 @@ pub fn make_gist<'a>(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: &[String], remove: &[String]) {
|
pub fn update_labels(issueref: &hubcaps::issues::IssueRef, add: &[String], remove: &[String]) {
|
||||||
let l = issue.labels();
|
let l = issueref.labels();
|
||||||
|
let issue = issueref.get().expect("Failed to get issue");
|
||||||
|
|
||||||
let existing: Vec<String> = issue
|
let existing: Vec<String> = issue.labels.iter().map(|l| l.name.clone()).collect();
|
||||||
.get()
|
|
||||||
.unwrap()
|
|
||||||
.labels
|
|
||||||
.iter()
|
|
||||||
.map(|l| l.name.clone())
|
|
||||||
.collect();
|
|
||||||
info!("Already: {:?}", existing);
|
|
||||||
|
|
||||||
let to_add = add
|
let to_add: Vec<&str> = add
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|l| !existing.contains(l)) // Remove labels already on the issue
|
.filter(|l| !existing.contains(l)) // Remove labels already on the issue
|
||||||
.map(|l| l.as_ref())
|
.map(|l| l.as_ref())
|
||||||
.collect();
|
.collect();
|
||||||
info!("Adding labels: {:?}", to_add);
|
|
||||||
|
|
||||||
let to_remove: Vec<String> = remove
|
let to_remove: Vec<String> = remove
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|l| existing.contains(l)) // Remove labels already on the issue
|
.filter(|l| existing.contains(l)) // Remove labels already on the issue
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
info!("Removing labels: {:?}", to_remove);
|
|
||||||
|
|
||||||
l.add(to_add).expect("Failed to add tags");
|
info!(
|
||||||
|
"Labeling issue #{}: + {:?} , - {:?}, = {:?}",
|
||||||
|
issue.id, to_add, to_remove, existing
|
||||||
|
);
|
||||||
|
|
||||||
|
l.add(to_add.clone()).unwrap_or_else(|e| {
|
||||||
|
panic!(
|
||||||
|
"Failed to add labels {:?} to issue #{}: {:?}",
|
||||||
|
to_add, issue.id, e
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
for label in to_remove {
|
for label in to_remove {
|
||||||
l.remove(&label).expect("Failed to remove tag");
|
l.remove(&label).unwrap_or_else(|e| {
|
||||||
|
panic!(
|
||||||
|
"Failed to remove label {:?} from issue #{}: {:?}",
|
||||||
|
label, issue.id, e
|
||||||
|
)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue