Merge pull request #1401 from gitbutlerapp/Fix-casts-and-types

refactor: update type conversions and remove unnecessary clippy lints
This commit is contained in:
Nikita Galaiko 2023-10-17 15:51:31 +02:00 committed by GitHub
commit 261ba4bf38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View File

@ -138,8 +138,14 @@ impl From<git2::IndexEntry> for IndexEntry {
impl From<IndexEntry> for git2::IndexEntry {
fn from(entry: IndexEntry) -> Self {
Self {
ctime: git2::IndexTime::new(entry.ctime.seconds() as i32, entry.ctime.nanoseconds()),
mtime: git2::IndexTime::new(entry.mtime.seconds() as i32, entry.mtime.nanoseconds()),
ctime: git2::IndexTime::new(
i32::try_from(entry.ctime.seconds()).unwrap(),
entry.ctime.nanoseconds(),
),
mtime: git2::IndexTime::new(
i32::try_from(entry.mtime.seconds()).unwrap(),
entry.mtime.nanoseconds(),
),
dev: entry.dev,
ino: entry.ino,
mode: entry.mode,

View File

@ -77,7 +77,6 @@
)]
//TODO: should probably be cleaned up as any of these could lead to panics or unexpected behaviour (the cast-ones)
#![allow(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_lossless,
clippy::match_same_arms,

View File

@ -79,6 +79,6 @@ mod tests {
});
let mut data_file = OpenOptions::new().read(true).open(data_path).unwrap();
let value = data_file.read_u32::<LittleEndian>().unwrap();
assert_eq!(value, num_threads as u32);
assert_eq!(value, u32::try_from(num_threads).unwrap());
}
}

View File

@ -20,7 +20,7 @@ pub struct BaseBranch {
pub remote_url: String,
pub base_sha: String,
pub current_sha: String,
pub behind: u32,
pub behind: usize,
pub upstream_commits: Vec<RemoteCommit>,
pub recent_commits: Vec<RemoteCommit>,
}
@ -485,7 +485,7 @@ pub fn target_to_base_branch(
remote_url: target.remote_url.clone(),
base_sha: target.sha.to_string(),
current_sha: oid.to_string(),
behind: upstream_commits.len() as u32,
behind: upstream_commits.len(),
upstream_commits,
recent_commits,
};