Skip to content

Commit 7a2a84c

Browse files
committed
Fixes basic clippy lints
1 parent 98ff3ac commit 7a2a84c

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ pub fn unify<'config>(config: &'config Config, repo: &Repository) -> Config<'con
3232
// like we do here is no longer sufficient. but until then, this is fine.
3333
one_fixup_per_commit: config.one_fixup_per_commit
3434
|| bool_value(
35-
&repo,
35+
repo,
3636
ONE_FIXUP_PER_COMMIT_CONFIG_NAME,
3737
ONE_FIXUP_PER_COMMIT_DEFAULT,
3838
),
3939
force_author: config.force_author
40-
|| bool_value(&repo, FORCE_AUTHOR_CONFIG_NAME, FORCE_AUTHOR_DEFAULT),
40+
|| bool_value(repo, FORCE_AUTHOR_CONFIG_NAME, FORCE_AUTHOR_DEFAULT),
4141
force_detach: config.force_detach
42-
|| bool_value(&repo, FORCE_DETACH_CONFIG_NAME, FORCE_DETACH_DEFAULT),
42+
|| bool_value(repo, FORCE_DETACH_CONFIG_NAME, FORCE_DETACH_DEFAULT),
4343
..*config
4444
}
4545
}
@@ -56,15 +56,15 @@ pub fn max_stack(repo: &git2::Repository) -> usize {
5656

5757
pub fn auto_stage_if_nothing_staged(repo: &git2::Repository) -> bool {
5858
bool_value(
59-
&repo,
59+
repo,
6060
AUTO_STAGE_IF_NOTHING_STAGED_CONFIG_NAME,
6161
AUTO_STAGE_IF_NOTHING_STAGED_DEFAULT,
6262
)
6363
}
6464

6565
pub fn fixup_target_always_sha(repo: &git2::Repository) -> bool {
6666
bool_value(
67-
&repo,
67+
repo,
6868
FIXUP_TARGET_ALWAYS_SHA_CONFIG_NAME,
6969
FIXUP_TARGET_ALWAYS_SHA_DEFAULT,
7070
)

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn run(logger: &slog::Logger, config: &Config) -> Result<()> {
2525
let repo = git2::Repository::open_from_env()?;
2626
debug!(logger, "repository found"; "path" => repo.path().to_str());
2727

28-
run_with_repo(&logger, &config, &repo)
28+
run_with_repo(logger, config, &repo)
2929
}
3030

3131
fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository) -> Result<()> {
@@ -35,7 +35,7 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
3535
));
3636
}
3737

38-
let config = config::unify(&config, repo);
38+
let config = config::unify(config, repo);
3939
let stack = stack::working_stack(
4040
repo,
4141
config.base,
@@ -382,7 +382,7 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
382382
// This simplifies writing tests that execute from within git-absorb's source directory
383383
// but operate on temporary repositories created elsewhere.
384384
// (The tests could explicitly change directories, but then must be serialized.)
385-
let repo_path = repo.path().parent().map(Path::to_str).flatten();
385+
let repo_path = repo.path().parent().and_then(Path::to_str);
386386
match repo_path {
387387
Some(path) => {
388388
command.args(["-C", path]);
@@ -816,7 +816,7 @@ mod tests {
816816
assert!(is_something_in_index);
817817

818818
let pre_absorb_ref_commit = ctx.repo.references_glob("PRE_ABSORB_HEAD").unwrap().last();
819-
assert!(matches!(pre_absorb_ref_commit, None));
819+
assert!(pre_absorb_ref_commit.is_none());
820820
}
821821

822822
#[test]
@@ -861,7 +861,7 @@ mod tests {
861861

862862
fn autostage_common(ctx: &repo_utils::Context, file_path: &PathBuf) -> (PathBuf, PathBuf) {
863863
// 1 modification w/o staging
864-
let path = ctx.join(&file_path);
864+
let path = ctx.join(file_path);
865865
let contents = std::fs::read_to_string(&path).unwrap();
866866
let modifications = format!("{contents}\nnew_line2");
867867
std::fs::write(&path, &modifications).unwrap();

src/stack.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ where
121121

122122
#[cfg(test)]
123123
mod tests {
124-
use tempfile;
125124

126125
use super::*;
127126

src/tests/repo_utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ lines
5656
/// Stage the changes made to `path`.
5757
pub fn add<'r>(repo: &'r git2::Repository, path: &Path) -> git2::Tree<'r> {
5858
let mut index = repo.index().unwrap();
59-
index.add_path(&path).unwrap();
59+
index.add_path(path).unwrap();
6060
index.write().unwrap();
6161

62-
let tree_id = index.write_tree_to(&repo).unwrap();
62+
let tree_id = index.write_tree_to(repo).unwrap();
6363
repo.find_tree(tree_id).unwrap()
6464
}
6565

@@ -71,15 +71,15 @@ pub fn prepare_and_stage() -> Context {
7171
}
7272

7373
/// Modify a file in the repository and stage the changes.
74-
pub fn stage_file_changes<'r>(ctx: &'r Context, file_path: &PathBuf) -> Tree<'r> {
74+
pub fn stage_file_changes<'r>(ctx: &'r Context, file_path: &Path) -> Tree<'r> {
7575
// add some lines to our file
76-
let path = ctx.join(&file_path);
76+
let path = ctx.join(file_path);
7777
let contents = std::fs::read_to_string(&path).unwrap();
7878
let modifications = format!("new_line1\n{contents}\nnew_line2");
7979
std::fs::write(&path, &modifications).unwrap();
8080

8181
// stage it
82-
add(&ctx.repo, &file_path)
82+
add(&ctx.repo, file_path)
8383
}
8484

8585
/// Set the named repository config option to value.

0 commit comments

Comments
 (0)