Skip to content

Enhance customALGoFiles feature#2273

Open
OleWunschmann wants to merge 23 commits into
microsoft:mainfrom
OleWunschmann:enhance-customALGoFiles-feature
Open

Enhance customALGoFiles feature#2273
OleWunschmann wants to merge 23 commits into
microsoft:mainfrom
OleWunschmann:enhance-customALGoFiles-feature

Conversation

@OleWunschmann

@OleWunschmann OleWunschmann commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

❔What, Why & How

This pull request enhances the AL-Go template update system by introducing a new mechanism for unconditionally removing files from repositories, expanding file specification options, and improving the logic for determining which files to include, exclude, or remove during updates. The changes also improve documentation and schema validation, and add new helper functions to streamline file resolution.

Key changes:

1. File Removal Functionality

  • Added support for a new filesToRemove array in settings, allowing unconditional removal of files from repositories during updates, regardless of whether they exist in the template. This is reflected in both the PowerShell logic and the settings schema. [1] [2] [3] [4]

2. File Specification Enhancements

  • Introduced the destinationName property to file specifications, enabling files to be renamed when copied or removed, and updated the schema and logic accordingly. [1] [2]
  • Improved descriptions and documentation for filesToInclude and filesToExclude in the schema, clarifying propagation and behavior. [1] [2]

3. Update Logic Improvements

  • Refactored the logic for determining files to include, exclude, and remove:
    • Now merges default, repository, and (if present) original template settings for all three categories.
    • Deduplicates files based on destination paths.
    • Ensures files in filesToRemove are excluded from inclusion, and that exclusions are mapped more accurately. [1] [2]

4. Helper Functions and Documentation

  • Added ResolveFilePathsInDestinationFolder, a helper for resolving file specs that refer to files already in the destination (e.g., for removal), with detailed documentation.
  • Improved and clarified documentation for key functions, especially around file resolution and settings snapshot updates.

5. Minor Path Handling Fixes

  • Ensured that sourceFolder always has a trailing slash in file path resolution to prevent path errors.

Related to discussion: #2227

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

Copilot AI review requested due to automatic review settings June 3, 2026 15:24
@OleWunschmann
OleWunschmann requested a review from a team as a code owner June 3, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.filesToRemove support end-to-end (schema, defaults, resolution logic, docs, and release notes).
  • Update CheckForUpdates to read template repo settings via ReadSettings and 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.

Comment thread Tests/CheckForUpdates.Action.Test.ps1
Comment thread Tests/CheckForUpdates.Action.Test.ps1
Comment thread e2eTests/scenarios/CustomTemplate/runtest.ps1
Comment thread e2eTests/scenarios/CustomTemplate/runtest.ps1
Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 Outdated
Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Comment thread e2eTests/scenarios/CustomTemplate/runtest.ps1 Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Comment thread Scenarios/CustomizingALGoForGitHub.md
Comment on lines +789 to +805
"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."
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extended the schema and documentation for property destinationName

@OleWunschmann

Copy link
Copy Markdown
Contributor Author

@mazhelez The failing PS5 tests should be fixed now.

Comment thread RELEASENOTES.md
Comment thread RELEASENOTES.md
@OleWunschmann
OleWunschmann requested a review from spetersenms July 9, 2026 17:11
}
},
"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.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings July 21, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. A filesToRemove entry with a matching template file and destinationFolder = '..' produces a destinationFullPath outside the repository; CheckForUpdates.ps1 later converts it to a relative path and passes it to Remove-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)

Comment on lines +1168 to +1171
if ($null -ne $templateSettings) {
$filesToIncludeUnresolved += $templateSettings.customALGoFiles.filesToInclude
}
$filesToIncludeUnresolved += $settings.customALGoFiles.filesToInclude
Comment on lines +206 to 207
$removeFiles = @($filesToExclude) + @($filesToRemove) | Where-Object { $_ -and (Test-Path -Path $_.destinationFullPath -PathType Leaf) } | ForEach-Object {
$relativePath = Resolve-Path -Path $_.destinationFullPath -Relative

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These issues are already in the codebase and worked fine until now.

Comment thread Scenarios/CustomizingALGoForGitHub.md Outdated
Comment on lines +253 to +255
| 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) |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mazhelez mazhelez self-assigned this Jul 21, 2026
Copilot AI review requested due to automatic review settings July 21, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 destinationFolder to ../..., producing a filesToRemove entry outside $baseFolder; CheckForUpdates.ps1 later converts that to a relative traversal path and passes it to Remove-Item. Normalize each destinationFullPath and 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)

Comment on lines +1166 to +1178
# 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] })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was wrong and was fixed. Additionally I optimized the logic some more.

Comment on lines +1180 to +1192
# 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] })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was wrong and was fixed. Additionally I optimized the logic some more.

Comment thread Tests/CheckForUpdates.Action.Test.ps1 Outdated
(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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 23, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. ResolveFilePaths suppresses duplicate destinationFullPath values 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 destinationFullPath outside $baseFolder: for example, an entry with destinationFolder = '..' 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 to Remove-Item in the cloned workspace, enabling deletion attempts outside the repository or causing the update to fail. Normalize each destination with GetFullPath and reject paths that are not strictly within $baseFolder before 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
Comment thread Tests/CheckForUpdates.Action.Test.ps1 Outdated
}

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread Tests/CheckForUpdates.Action.Test.ps1 Outdated

$filesToInclude, $filesToExclude, $filesToRemove = GetFilesToUpdate -settings $settings -baseFolder $baseFolder -templateFolder $templateFolder

# filesToRemove should one entry resolved from the base folder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

(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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copilot AI review requested due to automatic review settings July 23, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1171

  • $settings is already the effective result of ReadSettings, which includes the consumer's cached .github/AL-Go-TemplateRepoSettings.doNotEdit.json. Appending it after the live $templateSettings therefore reintroduces stale template entries. If a custom template removes or changes an include/exclude/remove entry, the old entry remains active for this run (and a stale filesToRemove can still win), so the change still requires a second update. Pass consumer-only settings here, or let ReadSettings skip the cached template settings when live template settings are supplied.
    if ($null -ne $templateSettings) {
        $filesToIncludeUnresolved += $templateSettings.customALGoFiles.filesToInclude
    }
    $filesToIncludeUnresolved += $settings.customALGoFiles.filesToInclude

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1202

  • Template-resolved entries can construct destinationFullPath from destinationFolder/destinationName without checking that the result remains under $baseFolder. For example, a matching template file with a ../ destination can enter $filesToRemove, after which CheckForUpdates.ps1 resolves and removes that path. The source-prefix check in ResolveFilePaths does not protect the destination. Canonicalize every removal destination and reject it unless it is within the repository root.
    $filesToRemove =  @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    if ($hasOriginalTemplate) {
        $filesToRemove += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    }
    $filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)

Comment thread RELEASENOTES.md Outdated

The `customALGoFiles` setting of a custom template was only applied on the next Update (from `AL-Go-TemplateRepoSettings.doNotEdit.json`). Now the up-to-date settings of the custom template are used directly during "Update AL-Go System Files". The template's `filesToInclude`, `filesToExclude`, and `filesToRemove` settings are merged with the consumer repo's settings before resolution.

- **`filesToInclude`** now also resolves files from the original AL-Go template. Files present in the official template that are not overridden by your custom template are propagated to consumer repos. When a file exists in both, the custom template version takes precedence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copilot AI review requested due to automatic review settings July 24, 2026 12:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1210

  • Validate every resolved removal destination against the canonical $baseFolder boundary. A filesToRemove entry whose destinationFolder or destinationName contains .. can be resolved from a matching template file into a path outside the repository because ResolveFilePaths checks only the source path. That path is subsequently accepted by CheckForUpdates.ps1 and passed to Remove-Item, enabling deletion outside the cloned repository.
    $filesToRemove =  @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    if ($hasOriginalTemplate) {
        $filesToRemove += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    }
    $filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)

e2eTests/scenarios/CustomTemplate/runtest.ps1:454

  • Use the possessive “repo's,” not “repos's.”
# Check that optional custom file is present (in repos's filesToInclude)

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:830

  • Appending a separator does not make the containment check path-safe: line 885 still uses case-insensitive, wildcard-aware -like. On Linux, sourceFolder = ../Repo can therefore pass the check for a base folder named repo, even though /tmp/Repo is a distinct sibling; paths containing [ or ? are also interpreted as patterns. Canonicalize both paths and use a platform-appropriate ordinal prefix comparison (and a literal path for enumeration).
    $sourceFolder = Join-Path $sourceFolder '' # Ensure source folder has a trailing slash for correct path resolution

Comment on lines +124 to +125
UpdateCustomTemplateRepoSettingsSnapshot -baseFolder $baseFolder -templateFolder $templateFolder
$repoSettings = ReadSettings -buildMode '' -project '' -workflowName '' -userName '' -branchName '' -trigger '' | ConvertTo-HashTable -recurse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +1173 to +1181
# Send telemetery about customALGoFiles usage
if ($settings.customALGoFiles.filesToInclude.Count -gt 0) {
Trace-Information -Message "Usage: Custom AL-Go Files (Include)"
Trace-Information -Message "Usage: Custom AL-Go Files (Include) of repository"
}
if ($settings.customALGoFiles.filesToExclude.Count -gt 0) {
Trace-Information -Message "Usage: Custom AL-Go Files (Exclude)"
Trace-Information -Message "Usage: Custom AL-Go Files (Exclude) of repository"
}
if ($settings.customALGoFiles.filesToRemove.Count -gt 0) {
Trace-Information -Message "Usage: Custom AL-Go Files (Remove) of repository"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by removing the "of repository"

Copilot AI review requested due to automatic review settings July 24, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

Actions/CheckForUpdates/CheckForUpdates.ps1:124

  • Refreshing the tracked snapshot in the comparison checkout makes it invisible to the update. GetFilesToUpdate later reads the same template file and compares it with this already-overwritten destination, so no $updateFiles entry is created; CloneIntoNewFolder then clones the stale remote snapshot and never writes the refreshed content. The new E2E assertion at runtest.ps1:400 will therefore fail, and other workflows continue reading stale template settings. Merge the fresh settings in memory, or explicitly carry the snapshot into the cloned update folder.
    UpdateCustomTemplateRepoSettingsSnapshot -baseFolder $baseFolder -templateFolder $templateFolder
    $repoSettings = ReadSettings -buildMode '' -project '' -workflowName '' -userName '' -branchName '' -trigger '' | ConvertTo-HashTable -recurse

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1210

  • These newly resolved removal entries can point outside $baseFolder: a template-controlled destinationFolder or destinationName containing .. is used to construct destinationFullPath without a destination-boundary check. If the corresponding template source exists, CheckForUpdates later resolves and removes that path, allowing deletion outside the cloned repository (or causing the update to fail). Canonicalize each destination and reject any path outside the repository root before adding it to filesToRemove.
    $filesToRemove =  @(ResolveFilePaths -sourceFolder $templateFolder -originalSourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    if ($hasOriginalTemplate) {
        $filesToRemove += @(ResolveFilePaths -sourceFolder $originalTemplateFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)
    }
    $filesToRemove += @(ResolveFilePathsInDestinationFolder -destinationFolder $baseFolder -files $filesToRemoveUnresolved -projects $projects)

Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:1178

  • At this point ReadSettings has already merged custom-template and consumer-repository arrays, so a template-only include triggers the “of repository” event and no template-specific telemetry is emitted. This does not provide the separate repository/template usage tracking described by the PR. Preserve the two sources until telemetry is recorded (or emit template telemetry before merging).
        Trace-Information -Message "Usage: Custom AL-Go Files (Include) of repository"
    }
    if ($settings.customALGoFiles.filesToExclude.Count -gt 0) {
        Trace-Information -Message "Usage: Custom AL-Go Files (Exclude) of repository"

Copilot AI review requested due to automatic review settings July 24, 2026 13:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

# Remove files that are in $filesToExclude and exist in the repository
$removeFiles = $filesToExclude | Where-Object { $_ -and (Test-Path -Path $_.destinationFullPath -PathType Leaf) } | ForEach-Object {
# Remove files that are in $filesToExclude or $filesToRemove and exist in the repository
$removeFiles = @($filesToExclude) + @($filesToRemove) | Where-Object { $_ -and (Test-Path -Path $_.destinationFullPath -PathType Leaf) } | ForEach-Object {
Comment on lines 1170 to +1171
- originalSourceFullPath: The full path to the original source file in the original template repository (if any).
Always $null for filesToRemove entries.
Comment on lines +264 to +265
# Check that missing workflow file is present (in default filesToExclude)
(Join-Path (Get-Location) $missingWorkflowFileRelativePath) | Should -Exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants