From 7b9f4adf1452b988ae4bde03a740fb082aa0dddf Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Wed, 27 Sep 2023 13:24:33 +0800 Subject: [PATCH 1/2] some improvements 1. make CHANGELOG.MD to CHANGELOG.md for case-sensitive environment 2. move spec version bump from Other Changes to Features Added group --- .../mergedChangelog1.md | 5 ++++- .../ChangeLogResult.cs | 8 ++++++-- .../Azure.SDK.Management.ChangelogGen/Context.cs | 2 +- .../Report/Release.cs | 3 +++ .../Report/ReleaseNoteGroup.cs | 11 +++++++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen.Tests/mergedChangelog1.md b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen.Tests/mergedChangelog1.md index c4204f3f239..80398308fb4 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen.Tests/mergedChangelog1.md +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen.Tests/mergedChangelog1.md @@ -18,9 +18,12 @@ - Removed property method 'Set' for 'String PropertyToChangeToGet' in type Azure.ResourceManager.AppService.TestProperty - Removed type 'Azure.ResourceManager.AppService.TypeToBeDeleted' -### Other Changes +### Features Added - spec upgraded + +### Other Changes + - Azure Core upgraded - Azure RM upgraded - Obsoleted method 'Void StaticMethodToBeObsoleted()' in type Azure.ResourceManager.AppService.StaticTypeToBeObsoleted diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/ChangeLogResult.cs b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/ChangeLogResult.cs index 87ab76ab63d..08c91862519 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/ChangeLogResult.cs +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/ChangeLogResult.cs @@ -31,9 +31,13 @@ public Release GenerateReleaseNote(string version, string date, List 0) + report.Groups.Add(featureAddedGroup); + + ReleaseNoteGroup othersGroup = new ReleaseNoteGroup("Other Changes"); if (AzureCoreVersionChange != null) othersGroup.Notes.Add(new ReleaseNote(AzureCoreVersionChange.Description, PREFIX)); if (AzureResourceManagerVersionChange != null) diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Context.cs b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Context.cs index d2aeee90ba8..a73395ee18d 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Context.cs +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Context.cs @@ -49,7 +49,7 @@ public class Context public string AzureCoreChangeLogGithubKey => "sdk/core/Azure.Core/CHANGELOG.md"; public string AzureCoreChangeLogMdFile => Path.Combine(RepoRoot, AzureCoreChangeLogGithubKey); - public string AzureResourceManagerChangeLogGithubKey => "sdk/resourcemanager/Azure.ResourceManager/CHANGELOG.MD"; + public string AzureResourceManagerChangeLogGithubKey => "sdk/resourcemanager/Azure.ResourceManager/CHANGELOG.md"; public string AzureResourceManagerChangeLogMdFile => Path.Combine(RepoRoot, AzureResourceManagerChangeLogGithubKey); public bool IsPreview => Helper.IsPreviewRelease(this.ReleaseVersion); diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs index db875237a8d..40ca176bbd0 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs @@ -137,11 +137,13 @@ public static List FromChangelog(string changelog) { if (ReleaseNoteGroup.TryParseGroupTitle(lines[i], out ReleaseNoteGroup? newGroup)) { + curGroup.NormalizeNotes(); curRelease.Groups.Add(curGroup); curGroup = newGroup!; } else if (Release.TryParseReleaseTitle(lines[i], out Release? newRelease)) { + curGroup.NormalizeNotes(); curRelease.Groups.Add(curGroup); curGroup = new ReleaseNoteGroup(""); releases.Add(curRelease); @@ -153,6 +155,7 @@ public static List FromChangelog(string changelog) curGroup.Notes.Add(item); } } + curGroup.NormalizeNotes(); curRelease.Groups.Add(curGroup); releases.Add(curRelease); return releases; diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs index 6287c225bc9..c2ff2b4ed2f 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs @@ -33,6 +33,17 @@ public static bool TryParseGroupTitle(string line, out ReleaseNoteGroup? group) } } + public void NormalizeNotes() + { + for (int i = this.Notes.Count - 1; i >= 0; i--) + { + if (string.IsNullOrEmpty(this.Notes[i].Note)) + this.Notes.RemoveAt(i); + else + break; + } + } + public override string ToString() { if (string.IsNullOrWhiteSpace(this.Name)) From 6e46eeefa700a4d07360c58729d5d2cd140a73fb Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Wed, 27 Sep 2023 13:47:33 +0800 Subject: [PATCH 2/2] small improve --- .../Report/Release.cs | 20 +++++++++---------- .../Report/ReleaseNoteGroup.cs | 11 ---------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs index 40ca176bbd0..07a7ae6d274 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/Release.cs @@ -70,7 +70,7 @@ private void MergeByOverwrite(Release to) private void MergeByGrup(Release to) { - foreach(var fromGroup in this.Groups) + foreach (var fromGroup in this.Groups) { var found = to.Groups.FirstOrDefault(g => g.Name == fromGroup.Name); if (found != null) @@ -81,21 +81,24 @@ private void MergeByGrup(Release to) private void MergeByLine(Release to) { - foreach(var fromGroup in this.Groups) + foreach (var fromGroup in this.Groups) { var toGroup = to.Groups.FirstOrDefault(g => string.Equals(g.Name, fromGroup.Name, StringComparison.OrdinalIgnoreCase)); - if(toGroup == null) + if (toGroup == null) { to.Groups.Add(fromGroup); } else { - foreach(var fromItem in fromGroup.Notes) + int indexToInsert = toGroup.Notes.FindLastIndex(n => !string.IsNullOrEmpty(n.Note)) + 1; + int lastNonEmptyIndex = fromGroup.Notes.FindLastIndex(n => !string.IsNullOrEmpty(n.Note)); + for (int i = lastNonEmptyIndex; i >= 0; i--) { + var fromItem = fromGroup.Notes[i]; var toItem = toGroup.Notes.FirstOrDefault(t => string.Equals(fromItem.ToString(), t.ToString(), StringComparison.OrdinalIgnoreCase)); - if(toItem == null) + if (toItem == null) { - toGroup.Notes.Add(fromItem); + toGroup.Notes.Insert(indexToInsert, fromItem); } else { @@ -133,17 +136,15 @@ public static List FromChangelog(string changelog) Release curRelease = firstRelease!; ReleaseNoteGroup curGroup = new ReleaseNoteGroup(""); - for(i = i+1; i < lines.Length; i++) + for (i = i + 1; i < lines.Length; i++) { if (ReleaseNoteGroup.TryParseGroupTitle(lines[i], out ReleaseNoteGroup? newGroup)) { - curGroup.NormalizeNotes(); curRelease.Groups.Add(curGroup); curGroup = newGroup!; } else if (Release.TryParseReleaseTitle(lines[i], out Release? newRelease)) { - curGroup.NormalizeNotes(); curRelease.Groups.Add(curGroup); curGroup = new ReleaseNoteGroup(""); releases.Add(curRelease); @@ -155,7 +156,6 @@ public static List FromChangelog(string changelog) curGroup.Notes.Add(item); } } - curGroup.NormalizeNotes(); curRelease.Groups.Add(curGroup); releases.Add(curRelease); return releases; diff --git a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs index c2ff2b4ed2f..6287c225bc9 100644 --- a/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs +++ b/tools/net-changelog-gen-mgmt/Azure.SDK.Management.ChangelogGen/Report/ReleaseNoteGroup.cs @@ -33,17 +33,6 @@ public static bool TryParseGroupTitle(string line, out ReleaseNoteGroup? group) } } - public void NormalizeNotes() - { - for (int i = this.Notes.Count - 1; i >= 0; i--) - { - if (string.IsNullOrEmpty(this.Notes[i].Note)) - this.Notes.RemoveAt(i); - else - break; - } - } - public override string ToString() { if (string.IsNullOrWhiteSpace(this.Name))