fix(core): avoid storing hash details for empty fileset (#29316)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Craigory Coppola 2024-12-12 22:13:58 -05:00 committed by GitHub
parent 99700c075c
commit 0d6667d156
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -332,11 +332,28 @@ impl HashPlanner {
file_set.starts_with("{projectRoot}/") || file_set.starts_with("!{projectRoot}/")
});
let project_file_set_inputs = project_file_set_inputs(project_name, project_file_sets);
// let workspace_file_set_inputs = workspace_file_set_inputs(workspace_file_sets);
let workspace_file_set_inputs = match workspace_file_sets.is_empty() {
true => vec![],
false => vec![workspace_file_set_inputs(workspace_file_sets)],
let project_inputs = if project_file_sets.is_empty() {
vec![
HashInstruction::ProjectConfiguration(project_name.to_string()),
HashInstruction::TsConfiguration(project_name.to_string()),
]
} else {
vec![
HashInstruction::ProjectFileSet(
project_name.to_string(),
project_file_sets.iter().map(|f| f.to_string()).collect(),
),
HashInstruction::ProjectConfiguration(project_name.to_string()),
HashInstruction::TsConfiguration(project_name.to_string()),
]
};
let workspace_file_set_inputs = if workspace_file_sets.is_empty() {
vec![]
} else {
vec![HashInstruction::WorkspaceFileSet(
workspace_file_sets.iter().map(|f| f.to_string()).collect(),
)]
};
let runtime_and_env_inputs = self_inputs.iter().filter_map(|i| match i {
Input::Runtime(runtime) => Some(HashInstruction::Runtime(runtime.to_string())),
@ -344,7 +361,7 @@ impl HashPlanner {
_ => None,
});
project_file_set_inputs
project_inputs
.into_iter()
.chain(workspace_file_set_inputs)
.chain(runtime_and_env_inputs)
@ -429,18 +446,3 @@ fn find_external_dependency_node_name<'a>(
None
}
}
fn project_file_set_inputs(project_name: &str, file_sets: Vec<&str>) -> Vec<HashInstruction> {
vec![
HashInstruction::ProjectFileSet(
project_name.to_string(),
file_sets.iter().map(|f| f.to_string()).collect(),
),
HashInstruction::ProjectConfiguration(project_name.to_string()),
HashInstruction::TsConfiguration(project_name.to_string()),
]
}
fn workspace_file_set_inputs(file_sets: Vec<&str>) -> HashInstruction {
HashInstruction::WorkspaceFileSet(file_sets.iter().map(|f| f.to_string()).collect())
}