From 305a2870259b8c2d65f6285fdf7e9a7002303293 Mon Sep 17 00:00:00 2001 From: azurepowershell Date: Thu, 11 Jan 2024 08:27:10 +0000 Subject: [PATCH] Sync tools folder from main branch to generation branch --- tools/RunVersionController.ps1 | 4 +-- .../Models/SyntaxChangelogGenerator.cs | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tools/RunVersionController.ps1 b/tools/RunVersionController.ps1 index 0a39b8e0d97c..a7d9642d585c 100644 --- a/tools/RunVersionController.ps1 +++ b/tools/RunVersionController.ps1 @@ -408,8 +408,6 @@ function Update-AzSyntaxChangelog if (-not (Test-Path $targetFile)) { New-Item -Path $targetFile -ItemType File } - $currentContent = Get-Content -Path $targetFile -Raw - $newContent = $changeLog + "`r`n" + $currentContent $regex = '####\s+(Az\.\w+)\s+(?![\d\.])' $matches = Select-String -Pattern $regex -InputObject $changelog -AllMatches foreach ($match in $matches.Matches) { @@ -419,6 +417,8 @@ function Update-AzSyntaxChangelog $replacement = "#### $moduleName $newVersion `r`n" $changelog = $changelog -replace [regex]::Escape($match.Value), $replacement } + $currentContent = Get-Content -Path $targetFile -Raw + $newContent = $changeLog + "`r`n" + $currentContent Set-Content -Path $targetFile -Value $newContent Remove-Item -Path $syntaxChangeLog } diff --git a/tools/VersionController/Models/SyntaxChangelogGenerator.cs b/tools/VersionController/Models/SyntaxChangelogGenerator.cs index 55888f5dd6b9..9da7142aa547 100644 --- a/tools/VersionController/Models/SyntaxChangelogGenerator.cs +++ b/tools/VersionController/Models/SyntaxChangelogGenerator.cs @@ -27,6 +27,7 @@ public class SyntaxChangelogGenerator public void Analyze(String rootDirectory) { var srcDirs = Path.Combine(rootDirectory, @"src\"); + var toolsCommonDirs = Path.Combine(rootDirectory, @"tools\Tools.Common"); var manifestFiles = Directory.EnumerateFiles(srcDirs, "*.psd1", SearchOption.AllDirectories) .Where(file => !Path.GetDirectoryName(file) @@ -43,13 +44,13 @@ public void Analyze(String rootDirectory) var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath); Directory.SetCurrentDirectory(executingPath); var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName); - var filePath = Path.Combine(executingPath, "SerializedCmdlets", $"{moduleName}.json"); + var filePath = Path.Combine(toolsCommonDirs, "SerializedCmdlets", $"{moduleName}.json"); if (!File.Exists(filePath)) continue; var oldModuleMetadata = ModuleMetadata.DeserializeCmdlets(filePath); - CmdletLoader.ModuleMetadata = newModuleMetadata; + CmdletLoader.ModuleMetadata = oldModuleMetadata; CompareModuleMetedata(oldModuleMetadata, newModuleMetadata, moduleName); } - var markDownPath = Path.Combine(rootDirectory, "documentation/SyntaxChangeLog/SyntaxChangeLog.md"); + var markDownPath = Path.Combine(rootDirectory, @"documentation/SyntaxChangeLog/SyntaxChangeLog.md"); GenerateMarkdown(markDownPath); Console.WriteLine("Cmdlets Differences written to {0}", markDownPath); } @@ -410,25 +411,26 @@ public void GenerateMarkdown(string filePath) { if (diffInfo[i].Type == ChangeType.CmdletAdd) { - if (diffInfo[i].Type == diffInfo[i-1].Type) { + if (i != 0 && diffInfo[i].Type == diffInfo[i-1].Type) { sb.AppendFormat(", `{0}`",diffInfo[i].CmdletName); - if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) { - sb.AppendFormat("\n"); - } } else { sb.AppendFormat("* Added cmdlet `{0}`", diffInfo[i].CmdletName); } + if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) { + sb.AppendFormat("\n"); + } } else if (diffInfo[i].Type == ChangeType.CmdletRemove) { - if (diffInfo[i].Type == diffInfo[i-1].Type) { + if (i != 0 && diffInfo[i].Type == diffInfo[i-1].Type) { sb.AppendFormat(", `{0}`",diffInfo[i].CmdletName); - if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) { - sb.AppendFormat("\n"); - } + } else { sb.AppendFormat("* Removed cmdlet `{0}`", diffInfo[i].CmdletName); } + if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) { + sb.AppendFormat("\n"); + } } else { @@ -518,7 +520,7 @@ private string GetDescription_ParameterTypeChange(CmdletDiffInformation info) } private string GetDescription_ParameterAttributeChange(CmdletDiffInformation info) { - return $"Parameter `-{info.ParameterName}` ValidateNotNullOrEmpty changed from {info.Before[0]} to {info.After[0]}"; + return $"Parameter `-{info.ParameterName}` ValidateNotNullOrEmpty changed from `{info.Before[0]}` to `{info.After[0]}`"; } private string GetDescription_OutputTypeChange(CmdletDiffInformation info) @@ -540,6 +542,7 @@ public string GetDescription(CmdletDiffInformation info) mapper.Add(ChangeType.ParameterAliasRemove, GetDescription_ParameterAliasRemove); mapper.Add(ChangeType.ParameterTypeChange, GetDescription_ParameterTypeChange); mapper.Add(ChangeType.OutputTypeChange, GetDescription_OutputTypeChange); + mapper.Add(ChangeType.ParameterAttributeChange, GetDescription_ParameterAttributeChange); if (mapper.ContainsKey(info.Type)) {