Skip to content

Sync tools code from main branch to generation branch #23936

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
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/RunVersionController.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
Expand Down
27 changes: 15 additions & 12 deletions tools/VersionController/Models/SyntaxChangelogGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand All @@ -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))
{
Expand Down