Skip to content

Commit 84b25c4

Browse files
authored
fix syntax changelog (#23934)
1 parent 2869b97 commit 84b25c4

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

tools/RunVersionController.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ function Update-AzSyntaxChangelog
408408
if (-not (Test-Path $targetFile)) {
409409
New-Item -Path $targetFile -ItemType File
410410
}
411-
$currentContent = Get-Content -Path $targetFile -Raw
412-
$newContent = $changeLog + "`r`n" + $currentContent
413411
$regex = '####\s+(Az\.\w+)\s+(?![\d\.])'
414412
$matches = Select-String -Pattern $regex -InputObject $changelog -AllMatches
415413
foreach ($match in $matches.Matches) {
@@ -419,6 +417,8 @@ function Update-AzSyntaxChangelog
419417
$replacement = "#### $moduleName $newVersion `r`n"
420418
$changelog = $changelog -replace [regex]::Escape($match.Value), $replacement
421419
}
420+
$currentContent = Get-Content -Path $targetFile -Raw
421+
$newContent = $changeLog + "`r`n" + $currentContent
422422
Set-Content -Path $targetFile -Value $newContent
423423
Remove-Item -Path $syntaxChangeLog
424424
}

tools/VersionController/Models/SyntaxChangelogGenerator.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class SyntaxChangelogGenerator
2727
public void Analyze(String rootDirectory)
2828
{
2929
var srcDirs = Path.Combine(rootDirectory, @"src\");
30+
var toolsCommonDirs = Path.Combine(rootDirectory, @"tools\Tools.Common");
3031
var manifestFiles = Directory.EnumerateFiles(srcDirs, "*.psd1", SearchOption.AllDirectories)
3132
.Where(file =>
3233
!Path.GetDirectoryName(file)
@@ -43,13 +44,13 @@ public void Analyze(String rootDirectory)
4344
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
4445
Directory.SetCurrentDirectory(executingPath);
4546
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
46-
var filePath = Path.Combine(executingPath, "SerializedCmdlets", $"{moduleName}.json");
47+
var filePath = Path.Combine(toolsCommonDirs, "SerializedCmdlets", $"{moduleName}.json");
4748
if (!File.Exists(filePath)) continue;
4849
var oldModuleMetadata = ModuleMetadata.DeserializeCmdlets(filePath);
49-
CmdletLoader.ModuleMetadata = newModuleMetadata;
50+
CmdletLoader.ModuleMetadata = oldModuleMetadata;
5051
CompareModuleMetedata(oldModuleMetadata, newModuleMetadata, moduleName);
5152
}
52-
var markDownPath = Path.Combine(rootDirectory, "documentation/SyntaxChangeLog/SyntaxChangeLog.md");
53+
var markDownPath = Path.Combine(rootDirectory, @"documentation/SyntaxChangeLog/SyntaxChangeLog.md");
5354
GenerateMarkdown(markDownPath);
5455
Console.WriteLine("Cmdlets Differences written to {0}", markDownPath);
5556
}
@@ -410,25 +411,26 @@ public void GenerateMarkdown(string filePath)
410411
{
411412
if (diffInfo[i].Type == ChangeType.CmdletAdd)
412413
{
413-
if (diffInfo[i].Type == diffInfo[i-1].Type) {
414+
if (i != 0 && diffInfo[i].Type == diffInfo[i-1].Type) {
414415
sb.AppendFormat(", `{0}`",diffInfo[i].CmdletName);
415-
if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) {
416-
sb.AppendFormat("\n");
417-
}
418416
} else {
419417
sb.AppendFormat("* Added cmdlet `{0}`", diffInfo[i].CmdletName);
420418
}
419+
if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) {
420+
sb.AppendFormat("\n");
421+
}
421422
}
422423
else if (diffInfo[i].Type == ChangeType.CmdletRemove)
423424
{
424-
if (diffInfo[i].Type == diffInfo[i-1].Type) {
425+
if (i != 0 && diffInfo[i].Type == diffInfo[i-1].Type) {
425426
sb.AppendFormat(", `{0}`",diffInfo[i].CmdletName);
426-
if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) {
427-
sb.AppendFormat("\n");
428-
}
427+
429428
} else {
430429
sb.AppendFormat("* Removed cmdlet `{0}`", diffInfo[i].CmdletName);
431430
}
431+
if (i + 1 == diffInfo.Count ||diffInfo[i].Type != diffInfo[i+1].Type) {
432+
sb.AppendFormat("\n");
433+
}
432434
}
433435
else
434436
{
@@ -518,7 +520,7 @@ private string GetDescription_ParameterTypeChange(CmdletDiffInformation info)
518520
}
519521
private string GetDescription_ParameterAttributeChange(CmdletDiffInformation info)
520522
{
521-
return $"Parameter `-{info.ParameterName}` ValidateNotNullOrEmpty changed from {info.Before[0]} to {info.After[0]}";
523+
return $"Parameter `-{info.ParameterName}` ValidateNotNullOrEmpty changed from `{info.Before[0]}` to `{info.After[0]}`";
522524
}
523525

524526
private string GetDescription_OutputTypeChange(CmdletDiffInformation info)
@@ -540,6 +542,7 @@ public string GetDescription(CmdletDiffInformation info)
540542
mapper.Add(ChangeType.ParameterAliasRemove, GetDescription_ParameterAliasRemove);
541543
mapper.Add(ChangeType.ParameterTypeChange, GetDescription_ParameterTypeChange);
542544
mapper.Add(ChangeType.OutputTypeChange, GetDescription_OutputTypeChange);
545+
mapper.Add(ChangeType.ParameterAttributeChange, GetDescription_ParameterAttributeChange);
543546

544547
if (mapper.ContainsKey(info.Type))
545548
{

0 commit comments

Comments
 (0)