Enhance customALGoFiles feature#2273
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR enhances the customALGoFiles behavior during “Update AL-Go System Files”, adding support for unconditional removals (filesToRemove) and improving custom-template behavior by merging template settings directly and resolving files from the original AL-Go template where applicable.
Changes:
- Add
customALGoFiles.filesToRemovesupport end-to-end (schema, defaults, resolution logic, docs, and release notes). - Update
CheckForUpdatesto read template repo settings viaReadSettingsand merge template settings during file resolution. - Expand automated coverage (unit + e2e) for include/exclude/remove resolution and custom-template propagation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| e2eTests/scenarios/CustomTemplate/runtest.ps1 | Extends e2e scenario to validate custom-template file include/exclude/remove propagation and workflow presence. |
| Tests/CheckForUpdates.Action.Test.ps1 | Adds unit tests for destination-folder resolution and expanded GetFilesToUpdate behaviors (including filesToRemove). |
| Actions/CheckForUpdates/CheckForUpdates.ps1 | Updates settings reading (incl. trigger) and wires template settings + filesToRemove into update/removal flow. |
| Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 | Implements ResolveFilePathsInDestinationFolder and extends GetFilesToUpdate to produce include/exclude/remove lists. |
| Actions/.Modules/settings.schema.json | Extends settings schema with customALGoFiles.filesToRemove and clarifying descriptions. |
| Actions/.Modules/ReadSettings.psm1 | Adds default filesToRemove array under customALGoFiles. |
| Scenarios/settings.md | Documents customALGoFiles.filesToRemove in settings reference. |
| Scenarios/CustomizingALGoForGitHub.md | Adds conceptual docs + examples for original-template resolution and filesToRemove. |
| RELEASENOTES.md | Documents enhanced customALGoFiles behavior and new filesToRemove. |
| "sourceFolder": { | ||
| "type": "string", | ||
| "description": "The source folder from which to remove files, relative to the template repository root." | ||
| }, | ||
| "filter": { | ||
| "type": "string", | ||
| "description": "A filter string to select which files to remove. It can contain '*' and '?' wildcards." | ||
| }, | ||
| "destinationFolder": { | ||
| "type": "string", | ||
| "description": "The destination folder where the files should be removed, relative to the repository root." | ||
| }, | ||
| "perProject": { | ||
| "type": "boolean", | ||
| "description": "Indicates whether the removal should be applied per project. In that case, destinationFolder is relative to each project folder." | ||
| } | ||
| } |
There was a problem hiding this comment.
I added the support for destinationName based on the same property of filesToInclude, which is also not documented or defined in the schema.
@mazhelez What do you think about adding the property for filesToInclude and filesToRemove in the documentation and schema?
There was a problem hiding this comment.
I extended the schema and documentation for property destinationName
|
@mazhelez The failing PS5 tests should be fixed now. |
| } | ||
| }, | ||
| "filesToRemove": { | ||
| "description": "An array of file specifications to unconditionally remove from the repository during 'Update AL-Go System Files', regardless of whether the files exist in the template. Useful for cleaning up files that have been removed from the template but may still exist in repositories.", |
There was a problem hiding this comment.
... regardless of whether the files exist in the template
That's the part that made us leave out filesToRemove from the initial implementation of "custom AL-Go files".
If the files are not in the template, they are not considered AL-Go files, so why would AL-Go clean them up?
There was a problem hiding this comment.
Right now a custom template (and AL-Go) cannot remove/rename a file, because these changes in the template are not propagated to repos that use it.
The current workaround is to keep the file in the template and add it to "filesToExclude". This works, but it’s messy and pollutes the template repository.
With filesToRemove a custom template could remove files in the final repositories without the need to keep them.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1205
- Removal destinations are not constrained to
$baseFolder. AfilesToRemoveentry with a matching template file anddestinationFolder = '..'produces adestinationFullPathoutside the repository;CheckForUpdates.ps1later converts it to a relative path and passes it toRemove-Item. Normalize every removal destination and reject paths that are not descendants of the repository root before returning this list.
$filesToRemove += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
}
$filesToRemove += @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
$filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
| if ($null -ne $templateSettings) { | ||
| $filesToIncludeUnresolved += $templateSettings.customALGoFiles.filesToInclude | ||
| } | ||
| $filesToIncludeUnresolved += $settings.customALGoFiles.filesToInclude |
| $removeFiles = @($filesToExclude) + @($filesToRemove) | Where-Object { $_ -and (Test-Path -Path $_.destinationFullPath -PathType Leaf) } | ForEach-Object { | ||
| $relativePath = Resolve-Path -Path $_.destinationFullPath -Relative |
There was a problem hiding this comment.
These issues are already in the codebase and worked fine until now.
| | Yes | No | Yes | File from **original template** is propagated | | ||
| | No | Yes | Yes | File from **custom template** is propagated | | ||
| | Yes | Yes | Yes | File from **custom template** is used (takes precedence) | |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1205
- The source-path boundary check does not validate the generated destination. A spec can match a legitimate template file while setting
destinationFolderto../..., producing afilesToRemoveentry outside$baseFolder;CheckForUpdates.ps1later converts that to a relative traversal path and passes it toRemove-Item. Normalize eachdestinationFullPathand reject entries outside the repository root before returning this removal list.
$filesToRemove += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
}
$filesToRemove += @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
$filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
| # Determine files to include | ||
| $filesToIncludeUnresolved = GetDefaultFilesToInclude -includeCustomTemplateFiles:$hasOriginalTemplate | ||
| if ($null -ne $templateSettings) { | ||
| $filesToIncludeUnresolved += $templateSettings.customALGoFiles.filesToInclude | ||
| } | ||
| $filesToIncludeUnresolved += $settings.customALGoFiles.filesToInclude | ||
| $filesToInclude = @() | ||
| if ($hasOriginalTemplate) { | ||
| $filesToInclude += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToIncludeUnresolved -projects $projects) | ||
| } | ||
| $filesToInclude += @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToIncludeUnresolved -projects $projects) | ||
| # Remove duplicates based on destinationFullPath, keeping the last one (setting > template settings > defaults; template folder > original template folder) | ||
| $filesToInclude = @($filesToInclude | Group-Object { $_.destinationFullPath } | Sort-Object -Property Name | ForEach-Object { $_.Group[-1] }) |
| # Determine files to exclude | ||
| $filesToExcludeUnresolved = GetDefaultFilesToExclude -settings $settings | ||
| if ($null -ne $templateSettings) { | ||
| $filesToExcludeUnresolved += $templateSettings.customALGoFiles.filesToExclude | ||
| } | ||
| $filesToExcludeUnresolved += $settings.customALGoFiles.filesToExclude | ||
| $filesToExclude = @() | ||
| if ($hasOriginalTemplate) { | ||
| $filesToExclude += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToExcludeUnresolved -projects $projects) | ||
| } | ||
| $filesToExclude += @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToExcludeUnresolved -projects $projects) | ||
| # Remove duplicates based on destinationFullPath, keeping the last one (setting > template settings > defaults; template folder > original template folder) | ||
| $filesToExclude = @($filesToExclude | Group-Object { $_.destinationFullPath } | Sort-Object -Property Name | ForEach-Object { $_.Group[-1] }) |
| (Join-Path (Get-Location) $defaultCustomFileName) | Should -Not -Exist | ||
| # Check that optional custom file is NOT present in final repository | ||
| (Join-Path (Get-Location) $optionalCustomFileName) | Should -Not -Exist | ||
| # Check that legacy workflow file is present in final repository |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (3)
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1178
- The stated precedence is not applied within a source folder.
ResolveFilePathssuppresses duplicatedestinationFullPathvalues as it iterates, and this unresolved list is ordered defaults → template settings → repository settings, so the first/default or template entry wins before this grouping can keep the last entry. A repository include targeting the same destination as a template include is therefore silently ignored. Resolve all candidates before deduplicating, or process the specifications in precedence order.
# Remove duplicates based on destinationFullPath, keeping the last one (setting > template settings > defaults; template folder > original template folder)
$filesToInclude = @($filesToInclude | Group-Object { $_.destinationFullPath } | Sort-Object -Property Name | ForEach-Object { $_.Group[-1] })
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1205
- Template-resolved removals can produce a
destinationFullPathoutside$baseFolder: for example, an entry withdestinationFolder = '..'is resolved from a valid template source and retained here, even though destination-folder resolution rejects the escaped target. The caller later converts this path to../...and passes it toRemove-Itemin the cloned workspace, enabling deletion attempts outside the repository or causing the update to fail. Normalize each destination withGetFullPathand reject paths that are not strictly within$baseFolderbefore returning removal entries.
$filesToRemove += @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
$filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
e2eTests/scenarios/CustomTemplate/runtest.ps1:364
- This assertion checks a custom text file, not a workflow file; the comment is misleading.
# Check that legacy workflow file is present in final repository
| $projects = @(GetProjectsFromRepository -baseFolder $baseFolder -projectsFromSettings $repoSettings.projects) | ||
|
|
||
| $filesToInclude, $filesToExclude = GetFilesToUpdate -settings $repoSettings -projects $projects -baseFolder $baseFolder -templateFolder $templateFolder -originalTemplateFolder $originalTemplateFolder | ||
| $filesToInclude, $filesToExclude, $filesToRemove = GetFilesToUpdate -settings $repoSettings -projects $projects -baseFolder $baseFolder -templateFolder $templateFolder -templateSettings $templateRepoSettings -originalTemplateFolder $originalTemplateFolder |
| } | ||
|
|
||
| It 'ResolveFilePaths skips files in folder whose name starts with source folder name' { | ||
| # Create a external file in folder whose name starts with the same prefix as sourceFolder |
|
|
||
| $filesToInclude, $filesToExclude, $filesToRemove = GetFilesToUpdate -settings $settings -baseFolder $baseFolder -templateFolder $templateFolder | ||
|
|
||
| # filesToRemove should one entry resolved from the base folder |
| (Join-Path (Get-Location) $customWorkflowfileRelativePath) | Should -Exist | ||
| Get-ContentLF -Path (Join-Path (Get-Location) $customWorkflowfileRelativePath) | Should -Be $finalRepoCustomWorkflowContent.Replace("`r", "").TrimEnd("`n") | ||
|
|
||
| # Check that default custom file is NOT present (in repos's filesToExclude and template's filesToInclude) |
❔What, Why & How
New file removal feature:
filesToRemovefield to thecustomALGoFilessection in both the in-memory settings and the JSON schema, allowing users to specify files that should always be removed from the repository during updates, regardless of their presence in the template. (Actions/.Modules/ReadSettings.psm1,Actions/.Modules/settings.schema.json) [1] [2]Update logic improvements:
Refactored the logic in
GetFilesToUpdateand related helper functions to mergefilesToInclude,filesToExclude, andfilesToRemovefrom both repository and template settings, propagate removals from upstream templates, and correctly resolve file paths for removal operations. (Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1) [1] [2] [3]Added the
ResolveFilePathsInDestinationFolderfunction to accurately identify files for removal in the target repository, supporting per-project and destination-relative path resolution. (Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1)Telemetry and settings handling:
Enhanced telemetry to track usage of
filesToInclude,filesToExclude, andfilesToRemovefor both repository and template settings, providing better insights into feature adoption. (Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1)Updated the call to
ReadSettingsto include the-triggerparameter, ensuring settings are read with the correct context. (Actions/CheckForUpdates/CheckForUpdates.ps1)Prepared for template settings merging by initializing
$templateRepoSettingsand adjusting template download logic. (Actions/CheckForUpdates/CheckForUpdates.ps1)Related to discussion: #2227
✅ Checklist