Skip to content

Commit dba5b8a

Browse files
committed
fix(lints): Fixed a series of lint warnings preventing release, and removed quite a bit of dead code in the process.
1 parent 562e9b5 commit dba5b8a

10 files changed

Lines changed: 50 additions & 138 deletions

File tree

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ See the [README.md](../README.md) for full usage and configuration details.
5151
"#]
5252

5353
use crate::shells::Shell;
54-
use clap::{Parser, Subcommand, arg, command};
54+
use clap::{Parser, Subcommand};
5555

5656
use crate::long_abouts::COMPLETE_ME;
5757
use crate::options::{

src/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn shallow_filter(shallow: &bool) -> bool {
5757
}
5858

5959
// Just a type wrapper around str to make it clear what we're working with
60+
/// A type alias for submodule names used throughout the configuration.
6061
pub type SubmoduleName = String;
6162

6263
/// Git options for a submodule
@@ -76,6 +77,7 @@ pub struct SubmoduleGitOptions {
7677
pub update: Option<SerializableUpdate>,
7778
}
7879

80+
#[allow(dead_code)]
7981
impl SubmoduleGitOptions {
8082
/// Create a new instance with defaults
8183
pub fn new(
@@ -104,6 +106,7 @@ impl SubmoduleGitOptions {
104106
}
105107

106108
/// Convert git submodule options to git2-compatible options
109+
#[allow(dead_code)]
107110
pub struct Git2SubmoduleOptions {
108111
ignore: git2::SubmoduleIgnore,
109112
update: git2::SubmoduleUpdate,
@@ -112,7 +115,9 @@ pub struct Git2SubmoduleOptions {
112115
}
113116

114117
/// Implementation for converting git2 submodule options
118+
#[allow(dead_code)]
115119
impl Git2SubmoduleOptions {
120+
/// Create a new `Git2SubmoduleOptions` from individual git2 option values.
116121
pub fn new(
117122
ignore: git2::SubmoduleIgnore,
118123
update: git2::SubmoduleUpdate,
@@ -171,6 +176,7 @@ impl Iterator for SubmoduleDefaults {
171176
}
172177
}
173178

179+
#[allow(dead_code)]
174180
impl SubmoduleDefaults {
175181
/// Returns a vector of SubmoduleDefaults with the current values (for comparison)
176182
pub fn get_values(&self) -> Vec<SubmoduleDefaults> {
@@ -223,9 +229,11 @@ pub struct SubmoduleAddOptions {
223229
/// Whether to create a shallow clone
224230
pub shallow: bool,
225231
/// Whether to skip initialization after adding
232+
#[allow(dead_code)]
226233
pub no_init: bool,
227234
}
228235

236+
#[allow(dead_code)]
229237
impl SubmoduleAddOptions {
230238
/// Create an add options from a SubmoduleEntry
231239
pub fn into_submodule_entry(self) -> SubmoduleEntry {
@@ -282,6 +290,7 @@ pub struct SubmoduleUpdateOptions {
282290
pub force: bool,
283291
}
284292

293+
#[allow(dead_code)]
285294
impl SubmoduleUpdateOptions {
286295
/// Create a new instance with defaults
287296
pub fn new(strategy: SerializableUpdate, recursive: bool, force: bool) -> Self {
@@ -349,6 +358,7 @@ pub struct OtherSubmoduleSettings {
349358
pub no_init: bool,
350359
}
351360

361+
#[allow(dead_code)]
352362
impl OtherSubmoduleSettings {
353363
/// Create a new instance with default values
354364
fn default() -> Self {
@@ -452,6 +462,7 @@ pub struct SubmoduleEntry {
452462
pub sparse_paths: Option<Vec<String>>,
453463
}
454464

465+
#[allow(dead_code)]
455466
impl SubmoduleEntry {
456467
/// Create a new submodule entry with defaults
457468
pub fn new(
@@ -597,6 +608,7 @@ impl SubmoduleEntry {
597608
url.rsplit(&['/', ':'][..]).next().unwrap_or("").to_string()
598609
}
599610

611+
/// Returns the git-specific options for this submodule entry.
600612
pub fn git_options(&self) -> SubmoduleGitOptions {
601613
SubmoduleGitOptions {
602614
ignore: self.ignore.clone(),
@@ -606,6 +618,7 @@ impl SubmoduleEntry {
606618
}
607619
}
608620

621+
/// Returns the non-git settings for this submodule entry (path, url, active state, etc.).
609622
pub fn settings(&self) -> OtherSubmoduleSettings {
610623
OtherSubmoduleSettings {
611624
name: None, // We don't have a name in this struct, so we leave it as None
@@ -703,6 +716,7 @@ impl Serialize for SubmoduleEntries {
703716
}
704717
}
705718

719+
#[allow(dead_code)]
706720
impl SubmoduleEntries {
707721
/// Create a new empty SubmoduleEntries
708722
pub fn new(
@@ -715,6 +729,7 @@ impl SubmoduleEntries {
715729
}
716730
}
717731

732+
/// Create a new empty `SubmoduleEntries` with default (empty) collections.
718733
pub fn default() -> Self {
719734
Self {
720735
submodules: Some(HashMap::new()),
@@ -749,6 +764,7 @@ impl SubmoduleEntries {
749764
self.clone()
750765
}
751766

767+
/// Returns a list of all submodule names, or `None` if no submodules are configured.
752768
pub fn submodule_names(&self) -> Option<Vec<String>> {
753769
self.submodules
754770
.as_ref()
@@ -823,6 +839,7 @@ impl SubmoduleEntries {
823839
self.submodules.as_ref()?.get(name)
824840
}
825841

842+
/// Returns `true` if a submodule with the given name exists.
826843
pub fn contains_key(&self, name: &str) -> bool {
827844
self.submodules
828845
.as_ref()
@@ -910,6 +927,7 @@ pub struct Config {
910927
pub submodules: SubmoduleEntries,
911928
}
912929

930+
#[allow(dead_code)]
913931
impl Config {
914932
/// Create a new configuration with the given defaults and submodules
915933
pub fn new(defaults: SubmoduleDefaults, submodules: SubmoduleEntries) -> Self {

src/git_manager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,13 @@ impl GitManager {
834834
}
835835

836836
/// Get mutable reference to the underlying config
837+
#[allow(dead_code)]
837838
pub const fn config_mut(&mut self) -> &mut Config {
838839
&mut self.config
839840
}
840841

841842
/// Get a clone of the underlying config
843+
#[allow(dead_code)]
842844
pub fn config_clone(&self) -> Config {
843845
self.config.clone()
844846
}
@@ -957,7 +959,7 @@ impl GitManager {
957959
};
958960

959961
// Build the current submodule map sorted by name for deterministic append order
960-
let mut current_entries: std::collections::BTreeMap<String, &SubmoduleEntry> =
962+
let current_entries: std::collections::BTreeMap<String, &SubmoduleEntry> =
961963
self.config.get_submodules().map(|(n, e)| (n.clone(), e)).collect();
962964

963965
// Track which names appeared in the existing file (so we know what to append)

src/git_ops/git2_ops.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl Git2Operations {
124124
Ok(shallow_file.exists())
125125
}
126126
/// Convert git2 status flags to our status flags
127+
#[allow(dead_code)]
127128
fn convert_git2_status_to_flags(&self, status: git2::SubmoduleStatus) -> SubmoduleStatusFlags {
128129
let mut flags = SubmoduleStatusFlags::empty();
129130
if status.contains(git2::SubmoduleStatus::IN_HEAD) {
@@ -171,6 +172,7 @@ impl Git2Operations {
171172
flags
172173
}
173174
/// Get git config at specified level
175+
#[allow(dead_code)]
174176
fn get_config_at_level(&self, level: ConfigLevel) -> Result<git2::Config> {
175177
match level {
176178
ConfigLevel::Local => self.repo.config(),
@@ -270,7 +272,7 @@ impl GitOperations for Git2Operations {
270272
if let (Some(name), Some(value)) = (entry.name(), entry.value()) {
271273
entries.insert(name.to_string(), value.to_string());
272274
}
273-
});
275+
})?;
274276
Ok(GitConfig { entries })
275277
}
276278
fn write_git_config(&self, config: &GitConfig, level: ConfigLevel) -> Result<()> {
@@ -716,6 +718,7 @@ impl GitOperations for Git2Operations {
716718
}
717719
impl Git2Operations {
718720
/// Get sparse checkout information for a submodule
721+
#[allow(dead_code)]
719722
fn get_sparse_checkout_info(&self, path: &str) -> Result<(bool, Vec<String>)> {
720723
let submodule = self
721724
.repo

src/git_ops/gix_ops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
use anyhow::{Context, Result};
66
use gix::bstr::ByteSlice;
77
use std::collections::HashMap;
8-
use std::path::{Path, PathBuf};
8+
use std::path::Path;
99

10-
use crate::git_ops::simple_gix::{clone_repo, fetch_repo};
11-
use crate::utilities::repo_from_path;
10+
use crate::git_ops::simple_gix::fetch_repo;
1211

1312
/// Parse a gix config file from raw bytes
1413
fn gix_file_from_bytes(bytes: Vec<u8>) -> Result<gix::config::File<'static>> {
@@ -23,7 +22,7 @@ fn gix_file_from_bytes(bytes: Vec<u8>) -> Result<gix::config::File<'static>> {
2322

2423
use super::{DetailedSubmoduleStatus, GitConfig, GitOperations, SubmoduleStatusFlags};
2524
use crate::config::{
26-
SubmoduleAddOptions, SubmoduleEntries, SubmoduleEntry, SubmoduleUpdateOptions,
25+
SubmoduleAddOptions, SubmoduleEntries, SubmoduleUpdateOptions,
2726
};
2827
use crate::options::{ConfigLevel, GitmodulesConvert};
2928
use crate::utilities;
@@ -100,6 +99,7 @@ impl GixOperations {
10099
}
101100

102101
/// Convert gix submodule status to our status flags
102+
#[allow(dead_code)]
103103
fn convert_gix_status_to_flags(&self, status: &gix::submodule::Status) -> SubmoduleStatusFlags {
104104
let mut flags = SubmoduleStatusFlags::empty();
105105
// Map gix status to our flags

src/git_ops/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ providing seamless integration for submodule management and configuration tasks.
1010
1111
We prefer Gix, but it's still unstable and several core features are missing, so we use git2 as a fallback for those features and for stability.
1212
"]
13+
/// git2-based git operations implementation
1314
pub mod git2_ops;
15+
/// gitoxide (gix)-based git operations implementation
1416
pub mod gix_ops;
1517
pub mod simple_gix;
1618
pub use git2_ops::Git2Operations;
@@ -28,6 +30,7 @@ use crate::options::{
2830
};
2931

3032
/// Represents git configuration state
33+
#[allow(dead_code)]
3134
#[derive(Debug, Clone, PartialEq, Eq)]
3235
pub struct GitConfig {
3336
/// Configuration entries as key-value pairs
@@ -70,6 +73,7 @@ bitflags! {
7073
}
7174

7275
/// Comprehensive submodule status information
76+
#[allow(dead_code)]
7377
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
7478
pub struct DetailedSubmoduleStatus {
7579
/// Path of the submodule
@@ -114,10 +118,13 @@ pub trait GitOperations {
114118
/// Write .gitmodules configuration
115119
fn write_gitmodules(&mut self, config: &SubmoduleEntries) -> Result<()>;
116120
/// Read git configuration at specified level
121+
#[allow(dead_code)]
117122
fn read_git_config(&self, level: ConfigLevel) -> Result<GitConfig>;
118123
/// Write git configuration at specified level
124+
#[allow(dead_code)]
119125
fn write_git_config(&self, config: &GitConfig, level: ConfigLevel) -> Result<()>;
120126
/// Set a single configuration value
127+
#[allow(dead_code)]
121128
fn set_config_value(&self, key: &str, value: &str, level: ConfigLevel) -> Result<()>;
122129

123130
// Submodule operations
@@ -132,12 +139,14 @@ pub trait GitOperations {
132139
/// Deinitialize a submodule
133140
fn deinit_submodule(&mut self, path: &str, force: bool) -> Result<()>;
134141
/// Get detailed status of a submodule
142+
#[allow(dead_code)]
135143
fn get_submodule_status(&self, path: &str) -> Result<DetailedSubmoduleStatus>;
136144
/// List all submodules
137145
fn list_submodules(&self) -> Result<Vec<String>>;
138146

139147
// Repository operations
140148
/// Fetch a submodule
149+
#[allow(dead_code)]
141150
fn fetch_submodule(&self, path: &str) -> Result<()>;
142151
/// Reset a submodule
143152
fn reset_submodule(&self, path: &str, hard: bool) -> Result<()>;

0 commit comments

Comments
 (0)