diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index 3aabac4..06c9561 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -45,7 +45,7 @@ fn main() { let mrw = tasks::massrebuilder::MassRebuildWorker::new( cloner, - nix, + &nix, cfg.github(), cfg.acl(), cfg.runner.identity.clone(), diff --git a/ofborg/src/checkout.rs b/ofborg/src/checkout.rs index c9dd4e2..e88b351 100644 --- a/ofborg/src/checkout.rs +++ b/ofborg/src/checkout.rs @@ -29,7 +29,7 @@ pub struct CachedProjectCo { } impl CachedCloner { - pub fn project(&self, name: String, clone_url: String) -> CachedProject { + pub fn project(&self, name: &str, clone_url: String) -> CachedProject { // /repo//clone // /repo//clone.lock // /repo/// @@ -290,7 +290,7 @@ mod tests { let hash = make_pr_repo(&bare.path(), &mk_co.path()); let cloner = cached_cloner(&workingdir.path()); - let project = cloner.project("commit-msg-list".to_owned(), bare.string()); + let project = cloner.project("commit-msg-list", bare.string()); let working_co = project .clone_for("testing-commit-msgs".to_owned(), "123".to_owned()) .expect("clone should work"); @@ -317,7 +317,7 @@ mod tests { let hash = make_pr_repo(&bare.path(), &mk_co.path()); let cloner = cached_cloner(&workingdir.path()); - let project = cloner.project("commit-files-changed-list".to_owned(), bare.string()); + let project = cloner.project("commit-files-changed-list", bare.string()); let working_co = project .clone_for("testing-files-changed".to_owned(), "123".to_owned()) .expect("clone should work"); diff --git a/ofborg/src/tagger.rs b/ofborg/src/tagger.rs index dc76eee..e7289fa 100644 --- a/ofborg/src/tagger.rs +++ b/ofborg/src/tagger.rs @@ -77,7 +77,7 @@ impl PkgsAddedRemovedTagger { t } - pub fn changed(&mut self, removed: Vec, added: Vec) { + pub fn changed(&mut self, removed: &[PackageArch], added: &[PackageArch]) { if removed.len() > 0 { self.selected.push(String::from("8.has: clean-up")); } diff --git a/ofborg/src/tasks/build.rs b/ofborg/src/tasks/build.rs index bf52037..4c25bb5 100644 --- a/ofborg/src/tasks/build.rs +++ b/ofborg/src/tasks/build.rs @@ -302,7 +302,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker { info!("Working on {}", job.pr.number); let project = self.cloner.project( - job.repo.full_name.clone(), + &job.repo.full_name, job.repo.clone_url.clone(), ); let co = project diff --git a/ofborg/src/tasks/githubcommentposter.rs b/ofborg/src/tasks/githubcommentposter.rs index d38cf6a..6882e1d 100644 --- a/ofborg/src/tasks/githubcommentposter.rs +++ b/ofborg/src/tasks/githubcommentposter.rs @@ -99,7 +99,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime) -> Chec let mut summary: Vec = vec![]; if let Some(ref attempted) = result.attempted_attrs { - summary.extend(list_segment("Attempted", attempted.clone())); + summary.extend(list_segment("Attempted", &attempted)); } if result.status == BuildStatus::TimedOut { @@ -112,7 +112,7 @@ fn result_to_check(result: &LegacyBuildResult, timestamp: DateTime) -> Chec "The following builds were skipped because they don't evaluate on {}", result.system ), - skipped.clone())); + &skipped)); } let text: String; @@ -193,7 +193,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String { reply.push("".to_owned()); if let Some(ref attempted) = result.attempted_attrs { - reply.extend(list_segment("Attempted", attempted.clone())); + reply.extend(list_segment("Attempted", &attempted)); } if let Some(ref skipped) = result.skipped_attrs { @@ -202,7 +202,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String { "The following builds were skipped because they don't evaluate on {}", result.system ), - skipped.clone())); + &skipped)); } if result.output.len() > 0 { @@ -217,7 +217,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String { reply.join("\n") } -fn list_segment(name: &str, things: Vec) -> Vec { +fn list_segment(name: &str, things: &[String]) -> Vec { let mut reply: Vec = vec![]; if things.len() > 0 { diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 1bed597..aa63cc3 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -68,7 +68,7 @@ impl LogMessageCollector { pub fn write_metadata(&mut self, from: &LogFrom, data: &BuildLogStart) -> Result<(), String>{ let metapath = self.path_for_metadata(&from)?; - let mut fp = self.open_file(metapath)?; + let mut fp = self.open_file(&metapath)?; match serde_json::to_string(data) { Ok(data) => { @@ -87,7 +87,7 @@ impl LogMessageCollector { pub fn write_result(&mut self, from: &LogFrom, data: &BuildResult) -> Result<(), String>{ let path = self.path_for_result(&from)?; - let mut fp = self.open_file(path)?; + let mut fp = self.open_file(&path)?; match serde_json::to_string(data) { Ok(data) => { @@ -110,7 +110,7 @@ impl LogMessageCollector { )) } else { let logpath = self.path_for_log(&from)?; - let fp = self.open_file(logpath)?; + let fp = self.open_file(&logpath)?; let writer = LineWriter::new(fp); self.handles.insert(from.clone(), writer); if let Some(handle) = self.handles.get_mut(&from) { @@ -157,7 +157,7 @@ impl LogMessageCollector { } } - fn open_file(&self, path: PathBuf) -> Result { + fn open_file(&self, path: &PathBuf) -> Result { let dir = path.parent().unwrap(); fs::create_dir_all(dir).unwrap(); @@ -369,12 +369,12 @@ mod tests { assert!( worker - .open_file(worker.path_for_log(&make_from("a")).unwrap()) + .open_file(&worker.path_for_log(&make_from("a")).unwrap()) .is_ok() ); assert!( worker - .open_file(worker.path_for_log(&make_from("b.foo/123")).unwrap()) + .open_file(&worker.path_for_log(&make_from("b.foo/123")).unwrap()) .is_ok() ); } diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 896be78..c4aceda 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -38,7 +38,7 @@ pub struct MassRebuildWorker { impl MassRebuildWorker { pub fn new( cloner: checkout::CachedCloner, - nix: nix::Nix, + nix: &nix::Nix, github: hubcaps::Github, acl: ACL, identity: String, @@ -71,8 +71,8 @@ impl MassRebuildWorker { if darwin { update_labels( &issue, - vec![String::from("6.topic: darwin")], - vec![], + &vec![String::from("6.topic: darwin")], + &vec![], ); } } @@ -86,8 +86,8 @@ impl MassRebuildWorker { update_labels( &issue, - tagger.tags_to_add(), - tagger.tags_to_remove(), + &tagger.tags_to_add(), + &tagger.tags_to_remove(), ); } } @@ -167,7 +167,7 @@ impl worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker 0 { let gist_url = make_gist( &gists, - String::from("Changed Paths"), + "Changed Paths", Some("".to_owned()), attrs .iter() @@ -570,8 +570,8 @@ impl worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker( gists: &hubcaps::gists::Gists<'a>, - name: String, + name: &str, description: Option, contents: String, ) -> Option { - let mut files = HashMap::new(); + let mut files: HashMap = HashMap::new(); files.insert( - name.clone(), + name.to_string(), hubcaps::gists::Content { - filename: Some(name.clone()), + filename: Some(name.to_string()), content: contents, }, ); @@ -618,7 +618,7 @@ fn make_gist<'a>( ) } -pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec, remove: Vec) { +pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: &Vec, remove: &Vec) { let l = issue.labels(); let existing: Vec = issue @@ -649,7 +649,7 @@ pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: Vec, remove } } -fn parse_commit_messages(messages: Vec) -> Vec { +fn parse_commit_messages(messages: &[String]) -> Vec { messages .iter() .filter_map(|line| { @@ -689,7 +689,7 @@ mod tests { ]; assert_eq!( parse_commit_messages( - " + &" firefox{-esr,}: fix failing build due to the google-api-key Merge pull request #34483 from andir/dovecot-cve-2017-15132 firefox: enable official branding @@ -705,7 +705,7 @@ mod tests { " .lines() .map(|l| l.to_owned()) - .collect(), + .collect::>(), ), expect );