Skip to content

[Eng] Update regex to match submodule x.autorest case insensitively #28120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2025

Conversation

VeryEarly
Copy link
Collaborator

Description

powershell -match operator is case insensitive by default : https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-7.5#common-features

to use case-sensitive match, use operator -cmatch`

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 03:20
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines the submodule lookup in AdaptAutorestModule.ps1 to only select Autorest submodules (case‐insensitive by default in PowerShell).

  • Changed the -match regex from a generic \. suffix to specifically \.Autorest
  • Limits directory selection to Autorest extensions only

@@ -50,7 +50,7 @@ if ($ModuleRootName -in $rootToParentMap.keys) {

$moduleRootPath = Join-Path $SourceDirectory $ModuleRootName
$subModuleNameTrimmed = $SubModuleName
$subModuleName = Get-ChildItem -Path $moduleRootPath -Directory | Where-Object { $_.Name -match "${subModuleNameTrimmed}\." } | ForEach-Object { $_.Name }
$subModuleName = Get-ChildItem -Path $moduleRootPath -Directory | Where-Object { $_.Name -match "${subModuleNameTrimmed}\.Autorest" } | ForEach-Object { $_.Name }
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

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

The regex isn't anchored and could match unintended names (e.g., ${subModuleNameTrimmed}.Autorestdir). Consider anchoring the pattern with start/end markers: ^${subModuleNameTrimmed}\.Autorest$.

Suggested change
$subModuleName = Get-ChildItem -Path $moduleRootPath -Directory | Where-Object { $_.Name -match "${subModuleNameTrimmed}\.Autorest" } | ForEach-Object { $_.Name }
$subModuleName = Get-ChildItem -Path $moduleRootPath -Directory | Where-Object { $_.Name -match "^${subModuleNameTrimmed}\.Autorest$" } | ForEach-Object { $_.Name }

Copilot uses AI. Check for mistakes.

@VeryEarly
Copy link
Collaborator Author

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@VeryEarly VeryEarly enabled auto-merge (squash) July 3, 2025 06:44
@VeryEarly VeryEarly merged commit 2dee6bb into main Jul 3, 2025
12 checks passed
@YanaXu YanaXu deleted the VeryEarly-patch-3 branch July 3, 2025 06:54
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.

2 participants