diff --git a/ofborg/src/files.rs b/ofborg/src/files.rs new file mode 100644 index 0000000..b945437 --- /dev/null +++ b/ofborg/src/files.rs @@ -0,0 +1,8 @@ +use std::io::Read; +use std::fs::File; + +pub fn file_to_str(f: &mut File) -> String { + let mut buffer = Vec::new(); + f.read_to_end(&mut buffer).expect("Reading eval output"); + return String::from(String::from_utf8_lossy(&buffer)); +} diff --git a/ofborg/src/lib.rs b/ofborg/src/lib.rs index a954f98..d5746df 100644 --- a/ofborg/src/lib.rs +++ b/ofborg/src/lib.rs @@ -36,6 +36,7 @@ pub mod config; pub mod message; pub mod tasks; pub mod evalchecker; +pub mod files; pub mod nix; pub mod stats; pub mod ghevent; @@ -61,6 +62,7 @@ pub mod ofborg { pub use message; pub use tasks; pub use evalchecker; + pub use files; pub use commitstatus; pub use ghevent; pub use nix; diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 2f59569..8a88cae 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -5,13 +5,12 @@ extern crate uuid; use uuid::Uuid; use std::collections::HashMap; -use std::fs::File; -use std::io::Read; use std::path::Path; use std::path::PathBuf; use ofborg::checkout; use ofborg::message::{massrebuildjob, buildjob}; use std::time::Instant; +use ofborg::files::file_to_str; use ofborg::nix; use ofborg::acl::ACL; use ofborg::stats; @@ -730,12 +729,6 @@ pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec, remove } } -fn file_to_str(f: &mut File) -> String { - let mut buffer = Vec::new(); - f.read_to_end(&mut buffer).expect("Reading eval output"); - return String::from(String::from_utf8_lossy(&buffer)); -} - fn parse_commit_messages(messages: Vec) -> Vec { messages .iter()