From 01f168540085ad086cd4c5bab67d66c478afbdf5 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 19 Nov 2017 19:05:15 -0500 Subject: [PATCH] Cleanup --- ofborg/src/bin/mass-rebuilder.rs | 5 +---- ofborg/src/message/massrebuildjob.rs | 7 +++++++ ofborg/src/outpathdiff.rs | 8 -------- ofborg/src/tasks/massrebuilder.rs | 18 ++++++++---------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index fedc926..86b02e6 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -7,9 +7,7 @@ extern crate log; use std::env; use std::path::Path; -use ofborg::worker::SimpleWorker; use ofborg::tasks; -use ofborg::message; use ofborg::config; use ofborg::checkout; use ofborg::nix; @@ -54,8 +52,7 @@ fn main() { let mrw = tasks::massrebuilder::MassRebuildWorker::new( cloner, nix, - cfg.github(), - cfg.checkout.root.clone() + cfg.github() ); /* println!("{:?}", mrw.consumer(&message::massrebuildjob::MassRebuildJob{ diff --git a/ofborg/src/message/massrebuildjob.rs b/ofborg/src/message/massrebuildjob.rs index 37c5662..2a8d91b 100644 --- a/ofborg/src/message/massrebuildjob.rs +++ b/ofborg/src/message/massrebuildjob.rs @@ -22,4 +22,11 @@ impl Actions { worker::Action::Ack ]; } + + pub fn done(&mut self, _job: &MassRebuildJob) -> worker::Actions { + return vec![ + worker::Action::Ack + ]; + } + } diff --git a/ofborg/src/outpathdiff.rs b/ofborg/src/outpathdiff.rs index 7b12b3b..58967fa 100644 --- a/ofborg/src/outpathdiff.rs +++ b/ofborg/src/outpathdiff.rs @@ -4,20 +4,12 @@ extern crate env_logger; use std::collections::HashMap; use std::fs::File; use std::fs; -use std::io::Read; use std::io::BufRead; use std::io::BufReader; -use std::path::Path; use std::path::PathBuf; -use ofborg::checkout; -use ofborg::message::massrebuildjob; use ofborg::nix; use std::io::Write; -use ofborg::worker; use ofborg::evalchecker::EvalChecker; -use ofborg::commitstatus::CommitStatus; -use amqp::protocol::basic::{Deliver,BasicProperties}; -use hubcaps; pub struct OutPathDiff { path: PathBuf, diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index f70aecd..2fc37bb 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -24,16 +24,14 @@ pub struct MassRebuildWorker { cloner: checkout::CachedCloner, nix: nix::Nix, github: hubcaps::Github, - tmp_root: String, } impl MassRebuildWorker { - pub fn new(cloner: checkout::CachedCloner, nix: nix::Nix, github: hubcaps::Github, tmp_root: String) -> MassRebuildWorker { + pub fn new(cloner: checkout::CachedCloner, nix: nix::Nix, github: hubcaps::Github) -> MassRebuildWorker { return MassRebuildWorker{ cloner: cloner, nix: nix, github: github, - tmp_root: tmp_root, }; } @@ -296,12 +294,12 @@ impl worker::SimpleWorker for MassRebuildWorker { update_labels(&issue, stdenvtagger.tags_to_add(), stdenvtagger.tags_to_remove()); - let mut rebuildTags = RebuildTagger::new(); + let mut rebuild_tags = RebuildTagger::new(); if let Some(attrs) = rebuildsniff.calculate_rebuild() { - rebuildTags.parse_attrs(attrs); + rebuild_tags.parse_attrs(attrs); } - update_labels(&issue, rebuildTags.tags_to_add(), - rebuildTags.tags_to_remove()); + update_labels(&issue, rebuild_tags.tags_to_add(), + rebuild_tags.tags_to_remove()); overall_status.set_with_description( "^.^!", @@ -315,7 +313,7 @@ impl worker::SimpleWorker for MassRebuildWorker { ); } - return vec![]; + return self.actions().done(&job); } } @@ -448,10 +446,10 @@ pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec, remove .collect(); info!("Removing labels: {:?}", to_remove); - l.add(to_add); + l.add(to_add).expect("Failed to add tags"); for label in to_remove { - l.remove(&label); + l.remove(&label).expect("Failed to remove tag"); } }