FeatureCheckTag
This commit is contained in:
parent
ac5f1caa23
commit
3d114918e4
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
@ -13,16 +13,13 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"s",
|
"s",
|
||||||
"X",
|
"X",
|
||||||
"D:/EC_Shares/EC_SPC_Si/SPC/Projects/Active",
|
"D:/5-Other-Small/Kanban-messa010ec/Kanban/Work-Items",
|
||||||
"Day-Helper-2024-10-02",
|
"Day-Helper-2024-09-11",
|
||||||
"14 point thickness.BAK_241001115400",
|
"*.json",
|
||||||
"DE_TS_",
|
".kanbn",
|
||||||
"DE_TS_EQU",
|
"Epic|Feature|User Story",
|
||||||
"L:/DevOps/Mesa_FI/File-Folder-Helper/.vscode/helper/iqs",
|
"L:/DevOps/Mesa_FI/File-Folder-Helper/.vscode/helper/tfs",
|
||||||
"666",
|
"https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/"
|
||||||
"777",
|
|
||||||
"888",
|
|
||||||
"999"
|
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
|
@ -158,8 +158,9 @@ internal static partial class Helper20240911
|
|||||||
spaces.RemoveAt(0);
|
spaces.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendLines(List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
private static void AppendLines(string url, List<char> spaces, List<string> lines, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||||
{
|
{
|
||||||
|
List<string> results = [];
|
||||||
WorkItem workItem;
|
WorkItem workItem;
|
||||||
string? maxIterationPath;
|
string? maxIterationPath;
|
||||||
List<string> distinct = [];
|
List<string> distinct = [];
|
||||||
@ -170,47 +171,203 @@ internal static partial class Helper20240911
|
|||||||
// continue;
|
// continue;
|
||||||
if (workItem.WorkItemType != workItemType)
|
if (workItem.WorkItemType != workItemType)
|
||||||
continue;
|
continue;
|
||||||
lines.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
if (keyValuePair.Value.Children.Count == 0)
|
if (keyValuePair.Value.Children.Count == 0)
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: true, sprintOnly: false);
|
AppendLines(spaces, results, keyValuePair.Value, condensed: true, sprintOnly: false);
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
distinct.Clear();
|
distinct.Clear();
|
||||||
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true);
|
||||||
if (distinct.Count > 1)
|
if (distinct.Count > 1)
|
||||||
{
|
{
|
||||||
lines.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
results.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}");
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})");
|
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
distinct.Sort();
|
distinct.Sort();
|
||||||
distinct = (from l in distinct select l.Trim()).Distinct().ToList();
|
distinct = (from l in distinct select l.Trim()).Distinct().ToList();
|
||||||
lines.AddRange(distinct);
|
results.AddRange(distinct);
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
maxIterationPath = distinct.Max();
|
maxIterationPath = distinct.Max();
|
||||||
if (!string.IsNullOrEmpty(maxIterationPath) && maxIterationPath.Contains("] ") && maxIterationPath.Split(']')[1].Trim() != workItem.IterationPath)
|
if (!string.IsNullOrEmpty(maxIterationPath) && maxIterationPath.Contains("] ") && maxIterationPath.Split(']')[1].Trim() != workItem.IterationPath)
|
||||||
{
|
{
|
||||||
lines.Add($"### Sync to Distinct Max Iteration Path => {maxIterationPath} - {workItem.Id} - {workItem.Title}");
|
results.Add($"### Sync to Distinct Max Iteration Path => {maxIterationPath} - {workItem.Id} - {workItem.Title}");
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lines.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
results.Add($"## Extended - {workItem.Id} - {workItem.Title}");
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
AppendLines(spaces, lines, keyValuePair.Value, condensed: false, sprintOnly: false);
|
AppendLines(spaces, results, keyValuePair.Value, condensed: false, sprintOnly: false);
|
||||||
lines.Add(string.Empty);
|
results.Add(string.Empty);
|
||||||
}
|
}
|
||||||
|
lines.AddRange(results);
|
||||||
|
results.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteFiles(string destinationDirectory, string fileName, ReadOnlyCollection<string> lines)
|
||||||
|
{
|
||||||
|
string text = string.Join(Environment.NewLine, lines);
|
||||||
|
string markdownFile = Path.Combine(destinationDirectory, $"{fileName}.md");
|
||||||
|
string textOld = !File.Exists(markdownFile) ? string.Empty : File.ReadAllText(markdownFile);
|
||||||
|
if (text != textOld)
|
||||||
|
File.WriteAllText(markdownFile, text);
|
||||||
|
string html = CommonMark.CommonMarkConverter.Convert(text);
|
||||||
|
string htmlFile = Path.Combine(destinationDirectory, $"{fileName}.html");
|
||||||
|
string htmlOld = !File.Exists(htmlFile) ? string.Empty : File.ReadAllText(htmlFile);
|
||||||
|
if (html != htmlOld)
|
||||||
|
File.WriteAllText(htmlFile, html);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<WorkItem> FilterChildren(Record record, ReadOnlyCollection<string> workItemTypes)
|
||||||
|
{
|
||||||
|
List<WorkItem> results = [];
|
||||||
|
WorkItem workItem;
|
||||||
|
foreach (KeyValuePair<int, Record> keyValuePair in record.Children)
|
||||||
|
{
|
||||||
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
|
if (!workItemTypes.Contains(workItem.WorkItemType))
|
||||||
|
continue;
|
||||||
|
results.Add(workItem);
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? GetMaxIterationPath(ReadOnlyCollection<WorkItem> workItems)
|
||||||
|
{
|
||||||
|
string? result;
|
||||||
|
List<string> results = [];
|
||||||
|
foreach (WorkItem workItem in workItems)
|
||||||
|
{
|
||||||
|
if (results.Contains(workItem.IterationPath))
|
||||||
|
continue;
|
||||||
|
results.Add(workItem.IterationPath);
|
||||||
|
}
|
||||||
|
result = results.Count == 0 ? null : results.Max();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FeatureCheckIterationPath(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||||
|
{
|
||||||
|
WorkItem workItem;
|
||||||
|
string? maxIterationPath;
|
||||||
|
List<string> results = [];
|
||||||
|
ReadOnlyCollection<WorkItem> workItems;
|
||||||
|
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||||
|
{
|
||||||
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
|
if (workItem.WorkItemType != workItemType)
|
||||||
|
continue;
|
||||||
|
results.Clear();
|
||||||
|
if (keyValuePair.Value.Children.Count == 0)
|
||||||
|
continue;
|
||||||
|
workItems = FilterChildren(keyValuePair.Value, workItemTypes);
|
||||||
|
maxIterationPath = GetMaxIterationPath(workItems);
|
||||||
|
if (string.IsNullOrEmpty(maxIterationPath) || workItem.IterationPath == maxIterationPath)
|
||||||
|
continue;
|
||||||
|
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
|
results.Add(string.Empty);
|
||||||
|
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
|
results.Add($"- [ ] {workItem.Id} => {workItem.IterationPath} != {maxIterationPath}");
|
||||||
|
results.Add(string.Empty);
|
||||||
|
lines.AddRange(results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<int> GetIdsNotMatching(string tags, ReadOnlyCollection<WorkItem> workItems)
|
||||||
|
{
|
||||||
|
List<int> results = [];
|
||||||
|
string[] segments;
|
||||||
|
string[] parentTags = tags.Split(';');
|
||||||
|
foreach (WorkItem workItem in workItems)
|
||||||
|
{
|
||||||
|
segments = tags.Split(';');
|
||||||
|
if (segments.Length > 0 && parentTags.Any(l => segments.Contains(l)))
|
||||||
|
continue;
|
||||||
|
results.Add(workItem.Id);
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FeatureCheckTag(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||||
|
{
|
||||||
|
WorkItem workItem;
|
||||||
|
List<string> results = [];
|
||||||
|
ReadOnlyCollection<int> idsNotMatching;
|
||||||
|
ReadOnlyCollection<WorkItem> workItems;
|
||||||
|
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||||
|
{
|
||||||
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
|
if (workItem.WorkItemType != workItemType)
|
||||||
|
continue;
|
||||||
|
results.Clear();
|
||||||
|
if (keyValuePair.Value.Children.Count == 0)
|
||||||
|
continue;
|
||||||
|
if (string.IsNullOrEmpty(workItem.Tags))
|
||||||
|
idsNotMatching = new([workItem.Id]);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
workItems = FilterChildren(keyValuePair.Value, workItemTypes);
|
||||||
|
idsNotMatching = GetIdsNotMatching(workItem.Tags, workItems);
|
||||||
|
if (!string.IsNullOrEmpty(workItem.Tags) && idsNotMatching.Count == 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
|
results.Add(string.Empty);
|
||||||
|
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
|
foreach (int id in idsNotMatching)
|
||||||
|
results.Add($"- [ ] {id} {nameof(workItem.Tags)} != {workItem.Tags}");
|
||||||
|
results.Add(string.Empty);
|
||||||
|
lines.AddRange(results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<int> GetIdsNotMatching(int? priority, ReadOnlyCollection<WorkItem> workItems)
|
||||||
|
{
|
||||||
|
List<int> results = [];
|
||||||
|
foreach (WorkItem workItem in workItems)
|
||||||
|
{
|
||||||
|
if (workItem.Priority == priority)
|
||||||
|
continue;
|
||||||
|
results.Add(workItem.Id);
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FeatureCheckPriority(string url, List<string> lines, ReadOnlyCollection<string> workItemTypes, ReadOnlyDictionary<int, Record> workItemAndChildren, string workItemType)
|
||||||
|
{
|
||||||
|
WorkItem workItem;
|
||||||
|
List<string> results = [];
|
||||||
|
ReadOnlyCollection<int> idsNotMatching;
|
||||||
|
ReadOnlyCollection<WorkItem> workItems;
|
||||||
|
foreach (KeyValuePair<int, Record> keyValuePair in workItemAndChildren)
|
||||||
|
{
|
||||||
|
workItem = keyValuePair.Value.WorkItem;
|
||||||
|
if (workItem.WorkItemType != workItemType)
|
||||||
|
continue;
|
||||||
|
results.Clear();
|
||||||
|
if (keyValuePair.Value.Children.Count == 0)
|
||||||
|
continue;
|
||||||
|
workItems = FilterChildren(keyValuePair.Value, workItemTypes);
|
||||||
|
idsNotMatching = GetIdsNotMatching(workItem.Priority, workItems);
|
||||||
|
if (idsNotMatching.Count == 0)
|
||||||
|
continue;
|
||||||
|
results.Add($"## {workItem.AssignedTo} - {workItem.Id} - {workItem.Title}");
|
||||||
|
results.Add(string.Empty);
|
||||||
|
results.Add($"- [{workItem.Id}]({url}{workItem.Id})");
|
||||||
|
foreach (int id in idsNotMatching)
|
||||||
|
results.Add($"- [ ] {id} {nameof(workItem.Priority)} != {workItem.Priority}");
|
||||||
|
results.Add(string.Empty);
|
||||||
|
lines.AddRange(results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void WriteMarkdown(ILogger<Worker> logger, List<string> args)
|
internal static void WriteMarkdown(ILogger<Worker> logger, List<string> args)
|
||||||
{
|
{
|
||||||
string old;
|
string url = args[6];
|
||||||
string html;
|
|
||||||
string text;
|
|
||||||
string checkFile;
|
|
||||||
List<char> spaces = [];
|
List<char> spaces = [];
|
||||||
List<string> lines = [];
|
List<string> lines = [];
|
||||||
string searchPattern = args[2];
|
string searchPattern = args[2];
|
||||||
@ -220,6 +377,8 @@ internal static partial class Helper20240911
|
|||||||
string destinationDirectory = Path.GetFullPath(args[5]);
|
string destinationDirectory = Path.GetFullPath(args[5]);
|
||||||
if (!Directory.Exists(destinationDirectory))
|
if (!Directory.Exists(destinationDirectory))
|
||||||
_ = Directory.CreateDirectory(destinationDirectory);
|
_ = Directory.CreateDirectory(destinationDirectory);
|
||||||
|
ReadOnlyCollection<string> userStoryWorkItemTypes = new(["User Story"]);
|
||||||
|
ReadOnlyCollection<string> userStoryTaskWorkItemTypes = new(["User Story", "Task"]);
|
||||||
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||||
logger.LogInformation("With search pattern '{SearchPattern}' found {files} file(s)", searchPattern, files.Length);
|
logger.LogInformation("With search pattern '{SearchPattern}' found {files} file(s)", searchPattern, files.Length);
|
||||||
ReadOnlyDictionary<int, WorkItem> workItems = GetWorkItems(filterDirectory, files);
|
ReadOnlyDictionary<int, WorkItem> workItems = GetWorkItems(filterDirectory, files);
|
||||||
@ -234,18 +393,34 @@ internal static partial class Helper20240911
|
|||||||
foreach (string workItemType in workItemTypes)
|
foreach (string workItemType in workItemTypes)
|
||||||
{
|
{
|
||||||
lines.Clear();
|
lines.Clear();
|
||||||
lines.AddRange(["# WorkItems", string.Empty]);
|
lines.Add("# WorkItems");
|
||||||
AppendLines(spaces, lines, workItemAndChildren, workItemType);
|
lines.Add(string.Empty);
|
||||||
checkFile = Path.Combine(destinationDirectory, $"{workItemType}.md");
|
AppendLines(url, spaces, lines, workItemAndChildren, workItemType);
|
||||||
text = string.Join(Environment.NewLine, lines);
|
WriteFiles(destinationDirectory, workItemType, new(lines));
|
||||||
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
}
|
||||||
if (text != old)
|
{
|
||||||
File.WriteAllText(checkFile, text);
|
lines.Clear();
|
||||||
checkFile = Path.Combine(destinationDirectory, $"{workItemType}.html");
|
string workItemType = "Feature";
|
||||||
html = CommonMark.CommonMarkConverter.Convert(text);
|
lines.Add($"# {nameof(FeatureCheckIterationPath)}");
|
||||||
old = !File.Exists(checkFile) ? string.Empty : File.ReadAllText(checkFile);
|
lines.Add(string.Empty);
|
||||||
if (html != old)
|
FeatureCheckIterationPath(url, lines, userStoryTaskWorkItemTypes, workItemAndChildren, workItemType);
|
||||||
File.WriteAllText(checkFile, html);
|
WriteFiles(destinationDirectory, $"{nameof(FeatureCheckIterationPath)}", new(lines));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
lines.Clear();
|
||||||
|
string workItemType = "Feature";
|
||||||
|
lines.Add($"# {nameof(FeatureCheckTag)}");
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
FeatureCheckTag(url, lines, userStoryWorkItemTypes, workItemAndChildren, workItemType);
|
||||||
|
WriteFiles(destinationDirectory, $"{nameof(FeatureCheckTag)}", new(lines));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
lines.Clear();
|
||||||
|
string workItemType = "Feature";
|
||||||
|
lines.Add($"# {nameof(FeatureCheckPriority)}");
|
||||||
|
lines.Add(string.Empty);
|
||||||
|
FeatureCheckPriority(url, lines, userStoryWorkItemTypes, workItemAndChildren, workItemType);
|
||||||
|
WriteFiles(destinationDirectory, $"{nameof(FeatureCheckPriority)}", new(lines));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user