Skip to content

Commit

Permalink
Rename get_filenames to collect_files (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 authored Feb 17, 2025
1 parent facd0af commit 302217d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/builtin/meta_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use fancy_regex::Regex;
use itertools::Itertools;
use rayon::iter::{IntoParallelIterator, ParallelIterator};

use crate::cli::run::{get_filenames, FileFilter, FileOptions};
use crate::cli::run::{collect_files, CollectOptions, FileFilter};
use crate::config::Language;
use crate::hook::{Hook, Project};
use crate::store::Store;
Expand All @@ -21,7 +21,7 @@ pub(crate) async fn check_hooks_apply(
) -> Result<(i32, Vec<u8>)> {
let store = Store::from_settings()?.init()?;

let input = get_filenames(FileOptions::default().with_all_files(true)).await?;
let input = collect_files(CollectOptions::default().with_all_files(true)).await?;

let mut code = 0;
let mut output = Vec::new();
Expand Down Expand Up @@ -89,7 +89,7 @@ pub(crate) async fn check_useless_excludes(
) -> Result<(i32, Vec<u8>)> {
let store = Store::from_settings()?.init()?;

let input = get_filenames(FileOptions::default().with_all_files(true)).await?;
let input = collect_files(CollectOptions::default().with_all_files(true)).await?;

let mut code = 0;
let mut output = Vec::new();
Expand Down
12 changes: 6 additions & 6 deletions src/cli/run/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'a> FileFilter<'a> {
}

#[derive(Default)]
pub struct FileOptions {
pub struct CollectOptions {
pub hook_stage: Option<Stage>,
pub from_ref: Option<String>,
pub to_ref: Option<String>,
Expand All @@ -173,7 +173,7 @@ pub struct FileOptions {
pub commit_msg_filename: Option<PathBuf>,
}

impl FileOptions {
impl CollectOptions {
pub fn with_all_files(mut self, all_files: bool) -> Self {
self.all_files = all_files;
self
Expand All @@ -182,8 +182,8 @@ impl FileOptions {

/// Get all filenames to run hooks on.
#[allow(clippy::too_many_arguments)]
pub async fn get_filenames(opts: FileOptions) -> Result<Vec<String>> {
let FileOptions {
pub async fn collect_files(opts: CollectOptions) -> Result<Vec<String>> {
let CollectOptions {
hook_stage,
from_ref,
to_ref,
Expand All @@ -192,7 +192,7 @@ pub async fn get_filenames(opts: FileOptions) -> Result<Vec<String>> {
commit_msg_filename,
} = opts;

let mut filenames = filenames_for_args(
let mut filenames = collect_files_from_args(
hook_stage,
from_ref,
to_ref,
Expand All @@ -214,7 +214,7 @@ pub async fn get_filenames(opts: FileOptions) -> Result<Vec<String>> {
}

#[allow(clippy::too_many_arguments)]
async fn filenames_for_args(
async fn collect_files_from_args(
hook_stage: Option<Stage>,
from_ref: Option<String>,
to_ref: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/run/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use filter::{get_filenames, FileFilter, FileOptions};
pub use filter::{collect_files, CollectOptions, FileFilter};
pub(crate) use run::{install_hooks, run};

mod filter;
Expand Down
4 changes: 2 additions & 2 deletions src/cli/run/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use constants::env_vars::EnvVars;

use crate::cli::reporter::{HookInitReporter, HookInstallReporter};
use crate::cli::run::keeper::WorkTreeKeeper;
use crate::cli::run::{get_filenames, FileFilter, FileOptions};
use crate::cli::run::{collect_files, CollectOptions, FileFilter};
use crate::cli::{ExitStatus, RunExtraArgs};
use crate::config::Stage;
use crate::fs::Simplified;
Expand Down Expand Up @@ -139,7 +139,7 @@ pub(crate) async fn run(
_guard = Some(WorkTreeKeeper::clean(&store).await?);
}

let filenames = get_filenames(FileOptions {
let filenames = collect_files(CollectOptions {
hook_stage,
from_ref,
to_ref,
Expand Down

0 comments on commit 302217d

Please sign in to comment.