From 12c76b9735a8fb037e14840e0fee0822f83e131d Mon Sep 17 00:00:00 2001 From: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> Date: Fri, 5 Jun 2020 20:48:42 +0800 Subject: [PATCH] Chenlei fix the issue of StackEdge (#12069) Co-authored-by: wyunchi-ms --- .../VersionController/Models/VersionBumper.cs | 3 +- .../Models/VersionFileHelper.cs | 7 ++-- tools/VersionController/Program.cs | 5 ++- .../Utilities/ModuleFilter.cs | 41 +++++++++++++++++++ .../VersionController.Netcore.csproj | 1 + tools/VersionController/WhiteList.csv | 2 + 6 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 tools/VersionController/Utilities/ModuleFilter.cs create mode 100644 tools/VersionController/WhiteList.csv diff --git a/tools/VersionController/Models/VersionBumper.cs b/tools/VersionController/Models/VersionBumper.cs index da10a673eec4..90119e7c2c21 100644 --- a/tools/VersionController/Models/VersionBumper.cs +++ b/tools/VersionController/Models/VersionBumper.cs @@ -6,6 +6,7 @@ using System.Reflection; using System.Text.RegularExpressions; using Tools.Common.Models; +using VersionController.Utilities; namespace VersionController.Models { @@ -296,7 +297,7 @@ private void UpdateDependentModules() .Where(f => !f.Contains("Netcore") && !f.Contains("bin") && !f.Contains("dll-Help") && - !f.Contains("Stack")) + !ModuleFilter.IsAzureStackModule(f)) .ToList(); foreach (var moduleManifestPath in moduleManifestPaths) { diff --git a/tools/VersionController/Models/VersionFileHelper.cs b/tools/VersionController/Models/VersionFileHelper.cs index 8a637952bddd..31acb82bf5d5 100644 --- a/tools/VersionController/Models/VersionFileHelper.cs +++ b/tools/VersionController/Models/VersionFileHelper.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using VersionController.Utilities; namespace VersionController.Models { @@ -65,11 +66,11 @@ public VersionFileHelper(string rootDirectory, string outputModuleManifestPath, public string ChangeLogPath => Directory.GetFiles(ProjectDirectory, "ChangeLog.md").FirstOrDefault(); public List AssemblyInfoPaths => Directory.GetFiles(SrcDirectory, "AssemblyInfo.cs", SearchOption.AllDirectories) - .Where(f => !f.Contains("Stack") && !f.Contains(".Test")) + .Where(f => !ModuleFilter.IsAzureStackModule(f) && !f.Contains(".Test")) .ToList(); - public string GalleryModuleDirectory => Path.Combine(OutputModuleDirectory, ModuleName); + public string GalleryModuleDirectory => OutputModuleDirectory; - public string GalleryModuleVersionDirectory => Directory.GetDirectories(GalleryModuleDirectory).FirstOrDefault(); + public string GalleryModuleVersionDirectory => GalleryModuleDirectory; } } diff --git a/tools/VersionController/Program.cs b/tools/VersionController/Program.cs index b8dccc5836e3..032ca04525a8 100644 --- a/tools/VersionController/Program.cs +++ b/tools/VersionController/Program.cs @@ -7,6 +7,7 @@ using System.Reflection; using Tools.Common.Models; using VersionController.Models; +using VersionController.Utilities; namespace VersionController { @@ -105,7 +106,7 @@ private static void BumpVersions() foreach (var directory in _projectDirectories) { var changeLogs = Directory.GetFiles(directory, "ChangeLog.md", SearchOption.AllDirectories) - .Where(f => (!f.Contains("Stack") || f.Contains("StackEdge")) && IsChangeLogUpdated(f)) + .Where(f => !ModuleFilter.IsAzureStackModule(f) && IsChangeLogUpdated(f)) .Select(f => GetModuleManifestPath(Directory.GetParent(f).FullName)) .Where(m => m.Contains(_moduleNameFilter)) .ToList(); @@ -170,7 +171,7 @@ private static void ValidateVersionBump() foreach (var directory in _projectDirectories) { var changeLogs = Directory.GetFiles(directory, "ChangeLog.md", SearchOption.AllDirectories) - .Where(f => !f.Contains("Stack")) + .Where(f => !ModuleFilter.IsAzureStackModule(f)) .Select(f => GetModuleManifestPath(Directory.GetParent(f).FullName)) .Where(m => !string.IsNullOrEmpty(m) && m.Contains(_moduleNameFilter)) .ToList(); diff --git a/tools/VersionController/Utilities/ModuleFilter.cs b/tools/VersionController/Utilities/ModuleFilter.cs new file mode 100644 index 000000000000..e7f13e105452 --- /dev/null +++ b/tools/VersionController/Utilities/ModuleFilter.cs @@ -0,0 +1,41 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; + +namespace VersionController.Utilities +{ + class ModuleFilter + { + public static bool IsAzureStackModule(String fileName) + { + bool isAzureStackModule = false; + if (fileName.Contains("Stack")) + { + isAzureStackModule = true; + } + var executingAssemblyPath = Assembly.GetExecutingAssembly().Location; + var versionControllerDirectory = Directory.GetParent(executingAssemblyPath).FullName; + var whiteListFile = Path.Combine(versionControllerDirectory, "WhiteList.csv"); + if (File.Exists(whiteListFile)) + { + var lines = File.ReadAllLines(whiteListFile).Skip(1).Where(c => !string.IsNullOrEmpty(c)); + foreach (var line in lines) + { + var cols = line.Split(",").Select(c => c.StartsWith("\"") ? c.Substring(1) : c) + .Select(c => c.EndsWith("\"") ? c.Substring(0, c.Length - 1) : c) + .Select(c => c.Trim()).ToArray(); + if (cols.Length >= 1) + { + if (fileName.Contains(cols[0])) + { + isAzureStackModule = false; + break; + } + } + } + } + return isAzureStackModule; + } + } +} diff --git a/tools/VersionController/VersionController.Netcore.csproj b/tools/VersionController/VersionController.Netcore.csproj index 84bdf70616cb..b8030c51dd78 100644 --- a/tools/VersionController/VersionController.Netcore.csproj +++ b/tools/VersionController/VersionController.Netcore.csproj @@ -48,6 +48,7 @@ + diff --git a/tools/VersionController/WhiteList.csv b/tools/VersionController/WhiteList.csv new file mode 100644 index 000000000000..107c12ef98d5 --- /dev/null +++ b/tools/VersionController/WhiteList.csv @@ -0,0 +1,2 @@ +Module +StackEdge