diff --git a/cargo-smart-release/src/commit/message.rs b/cargo-smart-release/src/commit/message.rs index dc7bfa9af47..4c3e3dc7d91 100644 --- a/cargo-smart-release/src/commit/message.rs +++ b/cargo-smart-release/src/commit/message.rs @@ -1,6 +1,5 @@ -use git_conventional::Type; use git_repository as git; -use git_repository::bstr::{BStr, ByteSlice}; +use git_repository::bstr::ByteSlice; use crate::commit::Message; diff --git a/cargo-smart-release/src/commit/mod.rs b/cargo-smart-release/src/commit/mod.rs index 0d0d7cfd7b6..a2a8481060d 100644 --- a/cargo-smart-release/src/commit/mod.rs +++ b/cargo-smart-release/src/commit/mod.rs @@ -1,6 +1,4 @@ -#![allow(unused)] - -use std::{borrow::Cow, collections::HashMap}; +use std::collections::HashMap; use git_repository as git; @@ -19,7 +17,7 @@ pub struct Message { pub breaking: bool, /// If set, this commit message body contains a specific description of the breaking change. pub breaking_description: Option, - /// all dditional information parsed from the title. + /// all additional information parsed from the title. pub additions: Vec, } diff --git a/git-odb/src/store_impls/dynamic/load_index.rs b/git-odb/src/store_impls/dynamic/load_index.rs index 6d72769ec03..311fe85d58c 100644 --- a/git-odb/src/store_impls/dynamic/load_index.rs +++ b/git-odb/src/store_impls/dynamic/load_index.rs @@ -457,7 +457,7 @@ impl super::Store { } /// returns Ok if the copy could happen because dest-slot was actually free or disposable , and Some(true) if it was empty - #[allow(clippy::too_many_arguments, unused_variables)] + #[allow(clippy::too_many_arguments)] fn try_set_index_slot( lock: &parking_lot::MutexGuard<'_, ()>, dest_slot: &MutableIndexAndPack, diff --git a/git-odb/tests/odb/store/dynamic.rs b/git-odb/tests/odb/store/dynamic.rs index 27d01a7df73..04755a7bfef 100644 --- a/git-odb/tests/odb/store/dynamic.rs +++ b/git-odb/tests/odb/store/dynamic.rs @@ -1,8 +1,5 @@ -#![allow(unused)] - use std::process::Command; -use git_features::threading::OwnShared; use git_odb::{store, Find, FindExt, Write}; use git_testtools::{fixture_path, hex_to_id}; @@ -132,7 +129,7 @@ fn multi_index_keep_open() -> crate::Result { "it opened the multi-pack index for iteration" ); let mut buf = Vec::new(); - use git_pack::{Find, FindExt}; + use git_pack::Find; let location = stable_handle .location_by_oid(oid, &mut buf) .expect("oid exists and is packed"); @@ -182,7 +179,7 @@ fn write() -> crate::Result { #[test] fn contains() { - let mut handle = db(); + let handle = db(); assert!(handle.contains(hex_to_id("37d4e6c5c48ba0d245164c4e10d5f41140cab980"))); // loose object assert_eq!( @@ -497,7 +494,7 @@ fn auto_refresh_with_and_without_id_stability() -> crate::Result { ); { - use git_pack::{Find, FindExt}; + use git_pack::Find; let mut stable_handle = handle.clone(); stable_handle.prevent_pack_unload(); let location = stable_handle diff --git a/git-pack/src/multi_index/write.rs b/git-pack/src/multi_index/write.rs index a95229ae61d..a5e158c3d6b 100644 --- a/git-pack/src/multi_index/write.rs +++ b/git-pack/src/multi_index/write.rs @@ -1,8 +1,6 @@ -#![allow(missing_docs, unused)] - +use std::sync::atomic::Ordering; use std::{ convert::TryInto, - io::Write, path::PathBuf, sync::atomic::AtomicBool, time::{Instant, SystemTime}, @@ -16,6 +14,7 @@ use crate::multi_index; mod error { /// The error returned by [multi_index::File::write_from_index_paths()][super::multi_index::File::write_from_index_paths()].. #[derive(Debug, thiserror::Error)] + #[allow(missing_docs)] pub enum Error { #[error(transparent)] Io(#[from] std::io::Error), @@ -36,10 +35,13 @@ pub(crate) struct Entry { index_mtime: SystemTime, } +/// Options for use in [`multi_index::File::write_from_index_paths()`]. pub struct Options { + /// The kind of hash to use for objects and to expect in the input files. pub object_hash: git_hash::Kind, } +/// The result of [`multi_index::File::write_from_index_paths()`]. pub struct Outcome

{ /// The calculated multi-index checksum of the file at `multi_index_path`. pub multi_index_checksum: git_hash::ObjectId, @@ -56,6 +58,9 @@ impl multi_index::File { 1 /*num base files */ + 4 /*num pack files*/; + /// Create a new multi-index file for writing to `out` from the pack index files at `index_paths`. + /// + /// Progress is sent to `progress` and interruptions checked via `should_interrupt`. pub fn write_from_index_paths

( mut index_paths: Vec, out: impl std::io::Write, @@ -66,7 +71,7 @@ impl multi_index::File { where P: Progress, { - let mut out = git_features::hash::Write::new(out, object_hash); + let out = git_features::hash::Write::new(out, object_hash); let (index_paths_sorted, index_filenames_sorted) = { index_paths.sort(); let file_names = index_paths @@ -98,6 +103,9 @@ impl multi_index::File { index_mtime: mtime, })); progress.inc(); + if should_interrupt.load(Ordering::Relaxed) { + return Err(Error::Interrupted); + } } progress.show_throughput(start); @@ -111,6 +119,9 @@ impl multi_index::File { }); entries.dedup_by_key(|e| e.id); progress.show_throughput(start); + if should_interrupt.load(Ordering::Relaxed) { + return Err(Error::Interrupted); + } entries }; @@ -138,7 +149,7 @@ impl multi_index::File { } let mut write_progress = progress.add_child("Writing multi-index"); - let mut write_start = Instant::now(); + let write_start = Instant::now(); write_progress.init( Some(cf.planned_storage_size() as usize + Self::HEADER_LEN), git_features::progress::bytes(), @@ -174,6 +185,9 @@ impl multi_index::File { unknown => unreachable!("BUG: forgot to implement chunk {:?}", std::str::from_utf8(&unknown)), } progress.inc(); + if should_interrupt.load(Ordering::Relaxed) { + return Err(Error::Interrupted); + } } }