Log Only
This commit is contained in:
@ -277,12 +277,18 @@ internal static partial class Helper20240108
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool SortFile(ILogger<Worker> logger, string cSharpFile, string[] lines)
|
||||
private static bool SortFile(ILogger<Worker> logger, bool logOnly, string cSharpFile, string[] lines)
|
||||
{
|
||||
bool result;
|
||||
ReadOnlyCollection<Method> methods = GetMethods(cSharpFile, logger, lines);
|
||||
if (methods.Count == 0)
|
||||
result = false;
|
||||
else if (logOnly)
|
||||
{
|
||||
foreach (Method method in methods.OrderBy(l => l.Name))
|
||||
logger.LogInformation("{cSharpFile} - {Name} has {lines} line(s)", cSharpFile, method.Name, (method.EndLine - method.StartLine).ToString("000000"));
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
result = WriteAllLines(cSharpFile, lines, methods);
|
||||
return result;
|
||||
@ -295,11 +301,12 @@ internal static partial class Helper20240108
|
||||
string[] lines;
|
||||
bool usePathCombine = true;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
bool logOnly = bool.Parse(args[3]);
|
||||
logger.LogInformation("{ticks}", ticks);
|
||||
string directory = Path.GetFullPath(args[2]);
|
||||
string repositoryDirectory = Path.GetFullPath(args[0]);
|
||||
string[] cSharpFiles = Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories);
|
||||
ReadOnlyCollection<string> gitOthersModifiedAndDeletedExcludingStandardFiles = Helpers.HelperGit.GetOthersModifiedAndDeletedExcludingStandardFiles(repositoryDirectory, usePathCombine, cancellationToken);
|
||||
ReadOnlyCollection<string> gitOthersModifiedAndDeletedExcludingStandardFiles = logOnly ? new(cSharpFiles) : Helpers.HelperGit.GetOthersModifiedAndDeletedExcludingStandardFiles(repositoryDirectory, usePathCombine, cancellationToken);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
foreach (string cSharpFile in cSharpFiles)
|
||||
@ -307,11 +314,11 @@ internal static partial class Helper20240108
|
||||
if (!gitOthersModifiedAndDeletedExcludingStandardFiles.Contains(cSharpFile))
|
||||
continue;
|
||||
lines = File.ReadAllLines(cSharpFile);
|
||||
check = SortFile(logger, cSharpFile, lines);
|
||||
check = SortFile(logger, logOnly, cSharpFile, lines);
|
||||
if (check && !result)
|
||||
result = true;
|
||||
}
|
||||
if (!result)
|
||||
if (logOnly || !result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user