@@ -32,16 +32,40 @@ if (-not $ToSha) {
3232
3333git fetch origin main
3434
35- $changedComponentFiles = Invoke-Expression " git diff --name-only $ ( $FromSha ) ...$ ( $ToSha ) -- components/"
36- $otherChanges = Invoke-Expression " git diff --name-only $ ( $FromSha ) ...$ ( $ToSha ) | Select-String -NotMatch '^components/'"
35+ $changedComponentFiles = Invoke-Expression " git diff --name-only $ ( $FromSha ) ...$ ( $ToSha ) -- components/" - ErrorAction Stop
36+ $otherChanges = Invoke-Expression " git diff --name-only $ ( $FromSha ) ...$ ( $ToSha ) | Select-String -NotMatch '^components/'" - ErrorAction Stop
3737
38- if (-not $otherChanges ) {
38+ # If one or more components is changed, return them in a list.
39+ $retChangedComponents = -not [string ]::IsNullOrWhiteSpace($changedComponentFiles );
40+
41+ # Return 'all' components when either:
42+ # - One or more files *outside* of a component folder is changed
43+ # - All files *inside* of component folders are unchanged
44+ # Both of these:
45+ # - Can happen when any non-component file is changed
46+ # - May indicate (but not guarantee) a build configuration change.
47+ # - Are a fallback to ensure that the script doesn't return an empty list of components.
48+ $retAllComponents = [string ]::IsNullOrWhiteSpace($changedComponentFiles ) -or -not [string ]::IsNullOrWhiteSpace($otherChanges );
49+
50+ Write-Output " Relevant vars: "
51+ Write-Output " `$ fromSha: $FromSha "
52+ Write-Output " `$ toSha: $ToSha "
53+ Write-Output " `$ changedComponentFiles: $changedComponentFiles "
54+ Write-Output " `$ otherChanges: $otherChanges "
55+ Write-Output " `$ retChangedComponents: $retChangedComponents "
56+ Write-Output " `$ retAllComponents: $retAllComponents "
57+
58+ if ($retAllComponents ) {
59+ return ' all' ;
60+ }
61+
62+ if ($retChangedComponents ) {
3963 $names = $changedComponentFiles | ForEach-Object { ($_ -replace ' ^components/' , ' ' ) -replace ' /.*$' , ' ' }
4064 $uniqueNames = $names | Sort-Object - Unique
4165 $quotedNames = $uniqueNames | ForEach-Object { " '$_ '" }
4266 $changedComponentsList = $quotedNames -join ' ,'
4367 return $changedComponentsList
4468}
45- else {
46- return ' all ' ;
47- }
69+
70+ Write-Error " Unhandled code path. "
71+ Write-Error " Please report this error to the author of this script. "
0 commit comments