From 329af88ca622d7d26db91778ecbef89101ff225a Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Fri, 6 Jan 2023 10:34:29 +0100 Subject: [PATCH] cob: Quiet warnings in release mode We were getting warnings in release mode, since the debug code is not being run, and some vars are mutable instead of immutable. Signed-off-by: Alexis Sellier --- radicle-cob/src/backend/git/change.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/radicle-cob/src/backend/git/change.rs b/radicle-cob/src/backend/git/change.rs index c445c60e..da83158a 100644 --- a/radicle-cob/src/backend/git/change.rs +++ b/radicle-cob/src/backend/git/change.rs @@ -11,7 +11,6 @@ use git_ext::Oid; use git_trailers::OwnedTrailer; use nonempty::NonEmpty; -use crate::git; use crate::history::entry::Timestamp; use crate::{ change::{self, store, Change}, @@ -228,28 +227,36 @@ where O: AsRef, { let resource = *resource.as_ref(); - - let mut parents = tips.iter().map(|o| *o.as_ref()).collect::>(); - parents.push(resource); + let parents = tips + .iter() + .map(|o| *o.as_ref()) + .chain(std::iter::once(resource)) + .collect::>(); let trailers: Vec = vec![trailers::ResourceCommitTrailer::from(resource).into()]; { let author = repo.signature()?; - let mut timestamp = author.when().seconds(); + let timestamp = author.when().seconds(); let mut headers = commit::Headers::new(); headers.push( "gpgsig", &String::from_utf8(crypto::ssh::ExtendedSignature::from(signature).to_armored())?, ); - let mut author = commit::Author::try_from(&author)?; + let author = commit::Author::try_from(&author)?; #[cfg(debug_assertions)] - if let Ok(s) = std::env::var(git::RAD_COMMIT_TIME) { - timestamp = s.trim().parse::().unwrap(); - author.time = git_commit::author::Time::new(timestamp, 0); - } + let (author, timestamp) = if let Ok(s) = std::env::var(crate::git::RAD_COMMIT_TIME) { + let timestamp = s.trim().parse::().unwrap(); + let author = commit::Author { + time: git_commit::author::Time::new(timestamp, 0), + ..author + }; + (author, timestamp) + } else { + (author, timestamp) + }; let oid = Commit::new( tree.id(),