Skip to content

Commit 815dd4e

Browse files
authored
Merge pull request #181 from arielf212/clippy-cleaning
Fixes basic clippy lints and runs clippy in the CI
2 parents 7f8c50c + 0dc1160 commit 815dd4e

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ jobs:
3232
- name: Check format
3333
run: cargo fmt --check
3434

35+
check-clippy:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Check clippy lints
40+
run: cargo clippy
41+
3542
build-man-page:
3643
name: build-man-page
3744
runs-on: ubuntu-latest

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
@@ -26,7 +26,7 @@ pub fn run(logger: &slog::Logger, config: &Config) -> Result<()> {
2626
let repo = git2::Repository::open_from_env()?;
2727
debug!(logger, "repository found"; "path" => repo.path().to_str());
2828

29-
run_with_repo(&logger, &config, &repo)
29+
run_with_repo(logger, config, &repo)
3030
}
3131

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

39-
let config = config::unify(&config, repo);
39+
let config = config::unify(config, repo);
4040
let stack = stack::working_stack(
4141
repo,
4242
config.base,
@@ -389,7 +389,7 @@ fn run_with_repo(logger: &slog::Logger, config: &Config, repo: &git2::Repository
389389
// This simplifies writing tests that execute from within git-absorb's source directory
390390
// but operate on temporary repositories created elsewhere.
391391
// (The tests could explicitly change directories, but then must be serialized.)
392-
let repo_path = repo.path().parent().map(Path::to_str).flatten();
392+
let repo_path = repo.path().parent().and_then(Path::to_str);
393393
match repo_path {
394394
Some(path) => {
395395
command.args(["-C", path]);
@@ -823,7 +823,7 @@ mod tests {
823823
assert!(is_something_in_index);
824824

825825
let pre_absorb_ref_commit = ctx.repo.references_glob("PRE_ABSORB_HEAD").unwrap().last();
826-
assert!(matches!(pre_absorb_ref_commit, None));
826+
assert!(pre_absorb_ref_commit.is_none());
827827
}
828828

829829
#[test]
@@ -868,7 +868,7 @@ mod tests {
868868

869869
fn autostage_common(ctx: &repo_utils::Context, file_path: &PathBuf) -> (PathBuf, PathBuf) {
870870
// 1 modification w/o staging
871-
let path = ctx.join(&file_path);
871+
let path = ctx.join(file_path);
872872
let contents = std::fs::read_to_string(&path).unwrap();
873873
let modifications = format!("{contents}\nnew_line2");
874874
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)