Update Subtasks In Markdown Files
Better ISO support Only reviewing Files when comparing Extracted sections from UpdateSubTasksInMarkdownFiles
This commit is contained in:
@ -133,31 +133,30 @@ internal static partial class HelperKanbanMetadata
|
||||
List<string> results = [kanbanIndexH1, string.Empty];
|
||||
string h1;
|
||||
TimeSpan timeSpan;
|
||||
List<string> lines;
|
||||
LineNumber lineNumber;
|
||||
Record[] sorted = (from l in records orderby l.GroupCount, l.FileInfo.LastWriteTime descending select l).ToArray();
|
||||
foreach (Record record in sorted)
|
||||
{
|
||||
if (record.ItemLineNumber == 0)
|
||||
throw new NotSupportedException();
|
||||
(lines, lineNumber) = HelperMarkdown.GetStatusAndFrontMatterYamlEndLineNumbers(record.FileInfo);
|
||||
if (lines.Count == 0)
|
||||
lineNumber = HelperMarkdown.GetLineNumbers(record.FileInfo);
|
||||
if (lineNumber.Lines.Count == 0)
|
||||
continue;
|
||||
timeSpan = new(record.FileInfo.LastWriteTime.Ticks - record.FileInfo.CreationTime.Ticks);
|
||||
h1 = lineNumber.H1 is null ? Path.GetFileNameWithoutExtension(record.FileInfo.Name) : lines[lineNumber.H1.Value];
|
||||
h1 = lineNumber.H1 is null ? Path.GetFileNameWithoutExtension(record.FileInfo.Name) : lineNumber.Lines[lineNumber.H1.Value];
|
||||
results.Add($"#{h1}");
|
||||
results.Add(string.Empty);
|
||||
results.Add("```yaml");
|
||||
results.Add($"CreationTime: {record.FileInfo.CreationTime:yyyy-MM-dd}");
|
||||
results.Add($"LastWriteTime: {record.FileInfo.LastWriteTime:yyyy-MM-dd}");
|
||||
results.Add($"TotalDays: {Math.Round(timeSpan.TotalDays, 2)}");
|
||||
if (lineNumber.FrontMatterYamlEnd is not null && lines.Count >= lineNumber.FrontMatterYamlEnd.Value)
|
||||
if (lineNumber.FrontMatterYamlEnd is not null && lineNumber.Lines.Count >= lineNumber.FrontMatterYamlEnd.Value)
|
||||
{
|
||||
for (int i = 0; i < lineNumber.FrontMatterYamlEnd; i++)
|
||||
{
|
||||
if (lines[i] == "---")
|
||||
if (lineNumber.Lines[i] == "---")
|
||||
continue;
|
||||
results.Add(lines[i]);
|
||||
results.Add(lineNumber.Lines[i]);
|
||||
}
|
||||
}
|
||||
results.Add($"status: {record.GroupCount}-{record.Group}");
|
||||
@ -175,7 +174,7 @@ internal static partial class HelperKanbanMetadata
|
||||
File.WriteAllText(file, string.Join(Environment.NewLine, results));
|
||||
}
|
||||
|
||||
internal static void SetMetadata(string sourceDirectory, ReadOnlyCollection<string> kanbanIndexFileLines, LineNumber kanbanIndexFileLineNumber, ReadOnlyCollection<string> gitOthersModifiedAndDeletedExcludingStandardFiles)
|
||||
internal static void SetMetadata(string sourceDirectory, LineNumber kanbanIndexFileLineNumber, ReadOnlyCollection<string> gitOthersModifiedAndDeletedExcludingStandardFiles)
|
||||
{
|
||||
bool? match;
|
||||
bool gitCheck;
|
||||
@ -184,23 +183,24 @@ internal static partial class HelperKanbanMetadata
|
||||
List<string> lines;
|
||||
LineNumber lineNumber;
|
||||
string? directory = Path.GetDirectoryName(sourceDirectory);
|
||||
List<Record> records = GetCollectionFromIndex(sourceDirectory, kanbanIndexFileLines);
|
||||
List<Record> records = GetCollectionFromIndex(sourceDirectory, kanbanIndexFileLineNumber.Lines);
|
||||
if (directory is not null && kanbanIndexFileLineNumber.H1 is not null)
|
||||
{
|
||||
string checkDirectory = Path.Combine(directory, ".vscode", "helper");
|
||||
if (Directory.Exists(checkDirectory))
|
||||
{
|
||||
WriteKanbanBoardFile(checkDirectory, records, kanbanIndexFileLines[kanbanIndexFileLineNumber.H1.Value]);
|
||||
WriteKanbanBoardYmlView(checkDirectory, records, kanbanIndexFileLines[kanbanIndexFileLineNumber.H1.Value]);
|
||||
WriteKanbanBoardFile(checkDirectory, records, kanbanIndexFileLineNumber.Lines[kanbanIndexFileLineNumber.H1.Value]);
|
||||
WriteKanbanBoardYmlView(checkDirectory, records, kanbanIndexFileLineNumber.Lines[kanbanIndexFileLineNumber.H1.Value]);
|
||||
}
|
||||
}
|
||||
foreach (Record record in records)
|
||||
{
|
||||
if (record.ItemLineNumber == 0)
|
||||
throw new NotSupportedException();
|
||||
(lines, lineNumber) = HelperMarkdown.GetStatusAndFrontMatterYamlEndLineNumbers(record.FileInfo);
|
||||
if (lines.Count == 0)
|
||||
lineNumber = HelperMarkdown.GetLineNumbers(record.FileInfo);
|
||||
if (lineNumber.Lines.Count == 0)
|
||||
continue;
|
||||
lines = lineNumber.Lines.ToList();
|
||||
statusLine = $"status: {record.GroupCount}-{record.Group}";
|
||||
paramCase = lineNumber.H1 is null ? null : GetParamCase(lines[lineNumber.H1.Value]);
|
||||
match = lineNumber.H1 is null || paramCase is null ? null : Path.GetFileNameWithoutExtension(record.FileInfo.Name) == paramCase;
|
||||
@ -235,8 +235,8 @@ internal static partial class HelperKanbanMetadata
|
||||
else
|
||||
{
|
||||
FileInfo fileInfo = new(indexFile);
|
||||
(List<string> lines, LineNumber lineNumber) = HelperMarkdown.GetStatusAndFrontMatterYamlEndLineNumbers(fileInfo);
|
||||
SetMetadata(fullPath, new(lines), lineNumber, gitOthersModifiedAndDeletedExcludingStandardFiles: new([]));
|
||||
LineNumber lineNumber = HelperMarkdown.GetLineNumbers(fileInfo);
|
||||
SetMetadata(fullPath, lineNumber, gitOthersModifiedAndDeletedExcludingStandardFiles: new([]));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user