Skip to content

Commit

Permalink
refactor(cli): use command runner to run predictable logic (#4176)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Oct 7, 2024
1 parent d5655e9 commit 64a84a6
Show file tree
Hide file tree
Showing 7 changed files with 342 additions and 225 deletions.
4 changes: 2 additions & 2 deletions crates/biome_cli/src/changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use std::ffi::OsString;
pub(crate) fn get_changed_files(
fs: &DynRef<'_, dyn FileSystem>,
configuration: &PartialConfiguration,
since: Option<String>,
since: Option<&str>,
) -> Result<Vec<OsString>, CliDiagnostic> {
let default_branch = configuration
.vcs
.as_ref()
.and_then(|v| v.default_branch.as_ref());

let base = match (since.as_ref(), default_branch) {
let base = match (since, default_branch) {
(Some(since), Some(_)) => since,
(Some(since), None) => since,
(None, Some(branch)) => branch,
Expand Down
9 changes: 7 additions & 2 deletions crates/biome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,13 @@ pub(crate) fn check(

let stdin = get_stdin(stdin_file_path, &mut *session.app.console, "check")?;

let vcs_targeted_paths =
get_files_to_process(since, changed, staged, &session.app.fs, &fs_configuration)?;
let vcs_targeted_paths = get_files_to_process(
since.as_deref(),
changed,
staged,
&session.app.fs,
&fs_configuration,
)?;

session
.app
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub(crate) fn ci(session: CliSession, payload: CiCommandPayload) -> Result<(), C
}

if changed {
paths = get_changed_files(&session.app.fs, &fs_configuration, since)?;
paths = get_changed_files(&session.app.fs, &fs_configuration, since.as_deref())?;
}

session
Expand Down
Loading

0 comments on commit 64a84a6

Please sign in to comment.