Skip to content

Commit

Permalink
Sync tools folder from main branch to generation branch (#23801)
Browse files Browse the repository at this point in the history
Co-authored-by: azurepowershell <azurepowershell@ms.com>
  • Loading branch information
azure-powershell-bot and azurepowershell authored Dec 21, 2023
1 parent 458d4b6 commit db78430
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 8 deletions.
4 changes: 4 additions & 0 deletions tools/CreateMappings_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -859,5 +859,9 @@
{
"module": "NetworkAnalytics",
"alias": "NetworkAnalytics"
},
{
"module": "Fleet",
"alias": "Fleet"
}
]
9 changes: 7 additions & 2 deletions tools/RunVersionController.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ Param(
[string]$GalleryName = "PSGallery",

[Parameter()]
[string]$ArtifactsOutputPath = "$PSScriptRoot/../artifacts/Release/"
[string]$ArtifactsOutputPath = "$PSScriptRoot/../artifacts/Release/",

[Parameter()]
[switch]$GenerateSyntaxChangelog
)

enum PSVersion
Expand Down Expand Up @@ -520,7 +523,9 @@ switch ($PSCmdlet.ParameterSetName)
# Refresh AzPreview.psd1
Update-AzPreview
Update-AzPreviewChangelog
Update-AzSyntaxChangelog
if ($GenerateSyntaxChangelog){
Update-AzSyntaxChangelog
}
# We need to generate the upcoming-breaking-changes.md after the process of bump version in minor release
if ([PSVersion]::MINOR -Eq $versionBump)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"Module","Sdk","Severity","ProblemId","Description","Remediation"
"Az.Compute","src/Compute/Compute.Management.Sdk","1","9080","Do not support updating SDK using autorest csharp v3.","Please update the Readme.md to generate code by autorest powershell v4."
44 changes: 40 additions & 4 deletions tools/VersionController/Models/SyntaxChangelogGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public void Analyze(String rootDirectory)
var moduleName = psd1FileName.Replace(".psd1", "");
if (ModuleFilter.IsAzureStackModule(moduleName.Replace("Az.", ""))) continue;
Console.WriteLine("Analyzing module: {0}", moduleName);
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
var executingPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
Directory.SetCurrentDirectory(executingPath);
var newModuleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
Console.WriteLine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", ".."));
var filePath = Path.Combine(executingPath, "SerializedCmdlets", $"{moduleName}.json");
if (!File.Exists(filePath)) continue;
var oldModuleMetadata = ModuleMetadata.DeserializeCmdlets(filePath);
Expand Down Expand Up @@ -277,9 +279,25 @@ join newParam in newParameterMetadatas on oldParam.Name equals newParam.Name
{
CompareChangedParameterAliases(moduleName, oldCmdletMetadata.Name, oldParameterMetadata, newParameterMetadata);
CompareChangedParameterType(moduleName, oldCmdletMetadata, oldParameterMetadata, newParameterMetadata);
CompareChangedParameterAttribute(moduleName, oldCmdletMetadata, oldParameterMetadata, newParameterMetadata);
}
}
void CompareChangedParameterAttribute(string moduleName, CmdletMetadata oldCmdletMetadata, ParameterMetadata oldParameterMetadata,
ParameterMetadata newParameterMetadata)
{
if (oldParameterMetadata.ValidateNotNullOrEmpty != newParameterMetadata.ValidateNotNullOrEmpty)
{
diffInfo.Add(new CmdletDiffInformation()
{
ModuleName = moduleName,
CmdletName = oldCmdletMetadata.Name,
Type = ChangeType.ParameterAttributeChange,
ParameterName = newParameterMetadata.Name,
Before = new List<string> { oldParameterMetadata.ValidateNotNullOrEmpty.ToString() },
After = new List<string> { newParameterMetadata.ValidateNotNullOrEmpty.ToString() },
});
}
}

private void CompareChangedParameterAliases(string moduleName, string cmdletName, ParameterMetadata oldParameterMetadata, ParameterMetadata newParameterMetadata)
{
if (!(oldParameterMetadata.AliasList.Count == newParameterMetadata.AliasList.Count
Expand Down Expand Up @@ -393,11 +411,25 @@ public void GenerateMarkdown(string filePath)
{
if (diffInfo[i].Type == ChangeType.CmdletAdd)
{
sb.AppendFormat("* Added cmdlet `{0}`\n", diffInfo[i].CmdletName);
if (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);
}
}
else if (diffInfo[i].Type == ChangeType.CmdletRemove)
{
sb.AppendFormat("* Removed cmdlet `{0}`\n", diffInfo[i].CmdletName);
if (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);
}
}
else
{
Expand Down Expand Up @@ -484,6 +516,10 @@ private string GetDescription_ParameterTypeChange(CmdletDiffInformation info)
{
return $"Changed the type of parameter `-{info.ParameterName}` from `{info.Before[0]}` to `{info.After[0]}`";
}
private string GetDescription_ParameterAttributeChange(CmdletDiffInformation info)
{
return $"Parameter `-{info.ParameterName}` ValidateNotNullOrEmpty changed from {info.Before[0]} to {info.After[0]}";
}

private string GetDescription_OutputTypeChange(CmdletDiffInformation info)
{
Expand Down
11 changes: 9 additions & 2 deletions tools/VersionController/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void Main(string[] args)
var executingAssemblyPath = Assembly.GetExecutingAssembly().Location;
var versionControllerDirectory = Directory.GetParent(executingAssemblyPath).FullName;
var artifactsDirectory = Directory.GetParent(versionControllerDirectory).FullName;

var syntaxChangelog = "false";
_rootDirectory = Directory.GetParent(artifactsDirectory).FullName;
_projectDirectories = new List<string>{ Path.Combine(_rootDirectory, @"src\") }.Where((d) => Directory.Exists(d)).ToList();
_outputDirectories = new List<string>{ Path.Combine(_rootDirectory, @"artifacts\Release\") }.Where((d) => Directory.Exists(d)).ToList();
Expand All @@ -74,9 +74,16 @@ public static void Main(string[] args)
_moduleNameFilter = args[1] + Psd1NameExtension;
}

if (args != null && args.Length > 2)
{
syntaxChangelog = args[2];
}

ConsolidateExceptionFiles(exceptionsDirectory);
ValidateManifest();
GenerateSyntaxChangelog(_rootDirectory);
if (syntaxChangelog.Equals("true", System.StringComparison.OrdinalIgnoreCase)) {
GenerateSyntaxChangelog(_rootDirectory);
}
BumpVersions();
}
private static void GenerateSyntaxChangelog(string _projectDirectories)
Expand Down

0 comments on commit db78430

Please sign in to comment.