prioritize.rs 661 B

1234567891011121314151617181920212223242526
  1. use crate::{
  2. config::PrioritizeConfig,
  3. github::{self, Event},
  4. handlers::Context,
  5. };
  6. use parser::command::prioritize::PrioritizeCommand;
  7. pub(super) async fn handle_command(
  8. ctx: &Context,
  9. config: &PrioritizeConfig,
  10. event: &Event,
  11. _: PrioritizeCommand,
  12. ) -> anyhow::Result<()> {
  13. let issue = event.issue().unwrap();
  14. let mut labels = issue.labels().to_owned();
  15. // Don't add the label if it's already there
  16. if !labels.iter().any(|l| l.name == config.label) {
  17. labels.push(github::Label {
  18. name: config.label.to_owned(),
  19. });
  20. }
  21. issue.set_labels(&ctx.github, labels).await?;
  22. Ok(())
  23. }