Remove StartAt
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Handle directoryInfo.LinkTarget GitRemoteRemove Handle directoryInfo.LinkTarget better Sort HelperMarkdown Sort Day 2024 Q2 u flag Better git remote management Gitea Echo
This commit is contained in:
parent
1cd20fa08b
commit
614588dcae
19
.gitea/workflows/echo.yml
Normal file
19
.gitea/workflows/echo.yml
Normal file
@ -0,0 +1,19 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -335,3 +335,5 @@ ASALocalRun/
|
||||
.extensions-vscode
|
||||
.extensions-vscode-oss
|
||||
.extensions-vscode-insiders
|
||||
|
||||
.vscode/.UserSecrets
|
||||
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -31,6 +31,7 @@
|
||||
"onenote",
|
||||
"pged",
|
||||
"Phares",
|
||||
"Reparse",
|
||||
"Rijndael",
|
||||
"Serilog",
|
||||
"SUBM",
|
||||
|
96
.vscode/tasks.json
vendored
96
.vscode/tasks.json
vendored
@ -105,94 +105,50 @@
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H Run Data Repository",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s J Verdaccio",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s J 'L:/Verdaccio/storage'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s M Self .Kanbn Tasks",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s M L:/DevOps/Mesa_FI/File-Folder-Helper L:/DevOps/Mesa_FI/File-Folder-Helper/.kanbn/tasks",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
|
||||
"args": [
|
||||
"s",
|
||||
"J",
|
||||
"L:/Verdaccio/storage",
|
||||
],
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s S BaGet",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s S 'L:/BaGet/packages'",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
|
||||
"args": [
|
||||
"s",
|
||||
"S",
|
||||
"L:/BaGet/packages",
|
||||
],
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s X SortCodeMethods",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s X L:/DevOps/Mesa_FI/File-Folder-Helper Day-Helper-2024-01-08 L:/DevOps/Mesa_FI/File-Folder-Helper/Day/2024-Q2",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08ANLYSDIFAAST230",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08ANLYSDIFAAST230\\Source\\MET08ANLYSDIFAAST230'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08DDUPSFS6420",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08DDUPSFS6420\\Source\\MET08DDUPSFS6420'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08DDUPSP1TBI",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08DDUPSP1TBI\\Source\\MET08DDUPSP1TBI'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08RESIHGCV",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08RESIHGCV\\Source\\MET08RESIHGCV'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08RESIMAPCDE",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08RESIMAPCDE\\Source\\MET08RESIMAPCDE'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08RESISRP2100",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08RESISRP2100\\Source\\MET08RESISRP2100'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08THFTIRQS408M",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08THFTIRQS408M\\Source\\MET08THFTIRQS408M'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H MET08THFTIRSTRATUS",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08THFTIRSTRATUS\\Source\\MET08THFTIRSTRATUS'",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s H WaferCounter",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s H '\\\\messa01ec.infineon.com\\apps\\WaferCounter\\BackupFiles'",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"L:/DevOps/Mesa_FI/File-Folder-Helper",
|
||||
"Day-Helper-2024-01-08",
|
||||
"L:/DevOps/Mesa_FI/File-Folder-Helper/Helpers"
|
||||
],
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "File-Folder-Helper AOT s F Staging _Logs",
|
||||
"type": "shell",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s F '\\\\messv02ecc1.ec.local\\EC_EAFLog\\Staging\\_ Logs'",
|
||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
|
||||
"args": [
|
||||
"s",
|
||||
"F",
|
||||
"'\\\\messv02ecc1.ec.local\\EC_EAFLog\\Staging\\_ Logs'",
|
||||
],
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
|
@ -13,6 +13,40 @@ internal static partial class Helper20240403
|
||||
string Pattern,
|
||||
string Primary);
|
||||
|
||||
private static void AlertIfNewDeviceIsConnected(DynamicHostConfigurationProtocolConfiguration dynamicHostConfigurationProtocolConfiguration, ILogger<Worker> logger)
|
||||
{
|
||||
string[] files = Directory.GetFiles(dynamicHostConfigurationProtocolConfiguration.Directory, dynamicHostConfigurationProtocolConfiguration.Pattern, SearchOption.TopDirectoryOnly);
|
||||
string? match = GetMatch(dynamicHostConfigurationProtocolConfiguration, files);
|
||||
if (string.IsNullOrEmpty(match))
|
||||
throw new NotSupportedException($"{dynamicHostConfigurationProtocolConfiguration.Primary} doesn't exist!");
|
||||
ReadOnlyDictionary<string, int> keyToCounts = GetKeyToCounts(dynamicHostConfigurationProtocolConfiguration, files);
|
||||
foreach (KeyValuePair<string, int> keyToCount in keyToCounts)
|
||||
{
|
||||
if (keyToCount.Value < 2)
|
||||
continue;
|
||||
logger.LogInformation("{Key}: {Count}", keyToCount.Key, keyToCount.Value);
|
||||
}
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<string, ReadOnlyCollection<string>>> keyValuePairs = GetKeyValuePairs(dynamicHostConfigurationProtocolConfiguration, files);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<string, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (!keyValuePair.Key.EndsWith(dynamicHostConfigurationProtocolConfiguration.Primary))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void AlertIfNewDeviceIsConnected(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
string ignore = args[6];
|
||||
string pattern = args[2];
|
||||
string primary = args[3];
|
||||
string keyIndex = args[5];
|
||||
string directory = args[0];
|
||||
logger.LogInformation(directory);
|
||||
string[] columns = args[4].Split('|');
|
||||
DynamicHostConfigurationProtocolConfiguration dynamicHostConfigurationProtocolConfiguration = new(columns, directory, ignore, int.Parse(keyIndex), pattern, primary);
|
||||
AlertIfNewDeviceIsConnected(dynamicHostConfigurationProtocolConfiguration, logger);
|
||||
}
|
||||
|
||||
private static string? GetMatch(DynamicHostConfigurationProtocolConfiguration dynamicHostConfigurationProtocolConfiguration, string[] files)
|
||||
{
|
||||
string? result = null;
|
||||
@ -114,38 +148,4 @@ internal static partial class Helper20240403
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void AlertIfNewDeviceIsConnected(DynamicHostConfigurationProtocolConfiguration dynamicHostConfigurationProtocolConfiguration, ILogger<Worker> logger)
|
||||
{
|
||||
string[] files = Directory.GetFiles(dynamicHostConfigurationProtocolConfiguration.Directory, dynamicHostConfigurationProtocolConfiguration.Pattern, SearchOption.TopDirectoryOnly);
|
||||
string? match = GetMatch(dynamicHostConfigurationProtocolConfiguration, files);
|
||||
if (string.IsNullOrEmpty(match))
|
||||
throw new NotSupportedException($"{dynamicHostConfigurationProtocolConfiguration.Primary} doesn't exist!");
|
||||
ReadOnlyDictionary<string, int> keyToCounts = GetKeyToCounts(dynamicHostConfigurationProtocolConfiguration, files);
|
||||
foreach (KeyValuePair<string, int> keyToCount in keyToCounts)
|
||||
{
|
||||
if (keyToCount.Value < 2)
|
||||
continue;
|
||||
logger.LogInformation("{Key}: {Count}", keyToCount.Key, keyToCount.Value);
|
||||
}
|
||||
ReadOnlyDictionary<string, ReadOnlyDictionary<string, ReadOnlyCollection<string>>> keyValuePairs = GetKeyValuePairs(dynamicHostConfigurationProtocolConfiguration, files);
|
||||
foreach (KeyValuePair<string, ReadOnlyDictionary<string, ReadOnlyCollection<string>>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
if (!keyValuePair.Key.EndsWith(dynamicHostConfigurationProtocolConfiguration.Primary))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void AlertIfNewDeviceIsConnected(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
string ignore = args[6];
|
||||
string pattern = args[2];
|
||||
string primary = args[3];
|
||||
string keyIndex = args[5];
|
||||
string directory = args[0];
|
||||
logger.LogInformation(directory);
|
||||
string[] columns = args[4].Split('|');
|
||||
DynamicHostConfigurationProtocolConfiguration dynamicHostConfigurationProtocolConfiguration = new(columns, directory, ignore, int.Parse(keyIndex), pattern, primary);
|
||||
AlertIfNewDeviceIsConnected(dynamicHostConfigurationProtocolConfiguration, logger);
|
||||
}
|
||||
|
||||
}
|
@ -21,27 +21,6 @@ internal static partial class Helper20240404
|
||||
string RegularExpressionPattern,
|
||||
string SearchPattern);
|
||||
|
||||
private static MetaData? GetMetaData(CommaSeparatedValuesConfiguration commaSeparatedValuesConfiguration, string fileNameWithoutExtension)
|
||||
{
|
||||
MetaData? result;
|
||||
Match match = Regex.Match(fileNameWithoutExtension, commaSeparatedValuesConfiguration.RegularExpressionPattern);
|
||||
if (!match.Success || match.Groups.Count != commaSeparatedValuesConfiguration.RegularExpressionGroupCount)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
int deviceId = int.Parse(match.Groups["DeviceId"].Value);
|
||||
int deviceNumber = int.Parse(match.Groups["DeviceNumber"].Value);
|
||||
result = new(deviceId,
|
||||
match.Groups["DeviceType"].Value,
|
||||
deviceNumber,
|
||||
match.Groups["DescriptionName"].Value,
|
||||
match.Groups["DescriptionTest"].Value,
|
||||
match.Groups["Frequency"].Value,
|
||||
match.Groups["Date"].Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void ParseCSV(CommaSeparatedValuesConfiguration commaSeparatedValuesConfiguration, ILogger<Worker> logger)
|
||||
{
|
||||
string line;
|
||||
@ -93,4 +72,25 @@ internal static partial class Helper20240404
|
||||
ParseCSV(commaSeparatedValuesConfiguration, logger);
|
||||
}
|
||||
|
||||
private static MetaData? GetMetaData(CommaSeparatedValuesConfiguration commaSeparatedValuesConfiguration, string fileNameWithoutExtension)
|
||||
{
|
||||
MetaData? result;
|
||||
Match match = Regex.Match(fileNameWithoutExtension, commaSeparatedValuesConfiguration.RegularExpressionPattern);
|
||||
if (!match.Success || match.Groups.Count != commaSeparatedValuesConfiguration.RegularExpressionGroupCount)
|
||||
result = null;
|
||||
else
|
||||
{
|
||||
int deviceId = int.Parse(match.Groups["DeviceId"].Value);
|
||||
int deviceNumber = int.Parse(match.Groups["DeviceNumber"].Value);
|
||||
result = new(deviceId,
|
||||
match.Groups["DeviceType"].Value,
|
||||
deviceNumber,
|
||||
match.Groups["DescriptionName"].Value,
|
||||
match.Groups["DescriptionTest"].Value,
|
||||
match.Groups["Frequency"].Value,
|
||||
match.Groups["Date"].Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -236,40 +236,6 @@ internal static partial class Helper20240517
|
||||
{
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<(string, string)> GetAggregationLines(string harFile)
|
||||
{
|
||||
List<(string, string)> results = [];
|
||||
if (!File.Exists(harFile))
|
||||
throw new Exception();
|
||||
string lastUrl = string.Empty;
|
||||
string text = "\"text\": \"{";
|
||||
string[] lines = File.ReadAllLines(harFile);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.Contains("\"url\": \""))
|
||||
lastUrl = line;
|
||||
if (!line.Contains(text))
|
||||
continue;
|
||||
if (!line.Contains("aggregations"))
|
||||
continue;
|
||||
if (lastUrl.Contains("search?asset=NONE"))
|
||||
continue;
|
||||
results.Add(new(lastUrl, line.Trim()[(text.Length - 1)..^1].Replace("\\\"", "\"")));
|
||||
lastUrl = string.Empty;
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
private static void SaveAmazon(IReadOnlyList<Datum> data, string personIdFile)
|
||||
{
|
||||
string json;
|
||||
Dictionary<string, Datum> keyValuePairs = [];
|
||||
foreach (Datum datum in data)
|
||||
_ = keyValuePairs.TryAdd(datum.Name.Split('.')[0], datum);
|
||||
json = JsonSerializer.Serialize(keyValuePairs, DictionaryDatumGenerationContext.Default.DictionaryStringDatum);
|
||||
File.WriteAllText(personIdFile, json);
|
||||
}
|
||||
|
||||
private static void SaveAmazon(string destination, string harFile)
|
||||
{
|
||||
string offset;
|
||||
@ -331,4 +297,38 @@ internal static partial class Helper20240517
|
||||
logger?.LogInformation("{harFiles} count", harFiles.Length);
|
||||
}
|
||||
|
||||
private static void SaveAmazon(IReadOnlyList<Datum> data, string personIdFile)
|
||||
{
|
||||
string json;
|
||||
Dictionary<string, Datum> keyValuePairs = [];
|
||||
foreach (Datum datum in data)
|
||||
_ = keyValuePairs.TryAdd(datum.Name.Split('.')[0], datum);
|
||||
json = JsonSerializer.Serialize(keyValuePairs, DictionaryDatumGenerationContext.Default.DictionaryStringDatum);
|
||||
File.WriteAllText(personIdFile, json);
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<(string, string)> GetAggregationLines(string harFile)
|
||||
{
|
||||
List<(string, string)> results = [];
|
||||
if (!File.Exists(harFile))
|
||||
throw new Exception();
|
||||
string lastUrl = string.Empty;
|
||||
string text = "\"text\": \"{";
|
||||
string[] lines = File.ReadAllLines(harFile);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (line.Contains("\"url\": \""))
|
||||
lastUrl = line;
|
||||
if (!line.Contains(text))
|
||||
continue;
|
||||
if (!line.Contains("aggregations"))
|
||||
continue;
|
||||
if (lastUrl.Contains("search?asset=NONE"))
|
||||
continue;
|
||||
results.Add(new(lastUrl, line.Trim()[(text.Length - 1)..^1].Replace("\\\"", "\"")));
|
||||
lastUrl = string.Empty;
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
}
|
@ -73,7 +73,7 @@ internal static partial class Helper20240624
|
||||
}
|
||||
}
|
||||
|
||||
internal static void MoveUpOndDirectory(ILogger<Worker> logger, List<string> args)
|
||||
internal static void MoveUpOneDirectory(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
string searchPattern = args[2];
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
|
79
Day/2024-Q3/Helper-2024-07-11.cs
Normal file
79
Day/2024-Q3/Helper-2024-07-11.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace File_Folder_Helper.Day;
|
||||
|
||||
internal static partial class Helper20240711
|
||||
{
|
||||
|
||||
internal static void GitRemoteRemove(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
string line;
|
||||
string[] lines;
|
||||
bool branchCheck;
|
||||
bool remoteCheck;
|
||||
string? directory;
|
||||
string? parentDirectory;
|
||||
string parentDirectoryName;
|
||||
string branchName = args[8];
|
||||
string searchPattern = args[2];
|
||||
string remoteToAddUrl = args[6];
|
||||
string remoteToRemove = args[3];
|
||||
string remoteToAddName = args[5];
|
||||
ReadOnlyCollection<string> messages;
|
||||
string remoteToRemoveFilter = args[4];
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
string lastRemoteSegment = remoteToRemove.Split('/')[^1];
|
||||
string extension = args[7].Length > 2 ? args[6] : string.Empty;
|
||||
string[] files = Directory.EnumerateFiles(sourceDirectory, searchPattern, new EnumerationOptions() { IgnoreInaccessible = true, RecurseSubdirectories = true, AttributesToSkip = FileAttributes.None }).ToArray();
|
||||
logger.LogInformation("Found {files} file(s)", files.Length);
|
||||
foreach (string file in files)
|
||||
{
|
||||
branchCheck = false;
|
||||
remoteCheck = false;
|
||||
lines = File.ReadAllLines(file);
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
line = lines[i];
|
||||
if (!line.Contains(remoteToRemove))
|
||||
continue;
|
||||
if (!lines[i - 1].Contains(remoteToRemoveFilter))
|
||||
continue;
|
||||
remoteCheck = true;
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
line = lines[i];
|
||||
if (!line.Contains(branchName))
|
||||
continue;
|
||||
branchCheck = true;
|
||||
break;
|
||||
}
|
||||
if (!remoteCheck)
|
||||
continue;
|
||||
directory = Path.GetDirectoryName(file);
|
||||
if (directory is null)
|
||||
continue;
|
||||
parentDirectory = Path.GetDirectoryName(directory);
|
||||
if (parentDirectory is null)
|
||||
continue;
|
||||
parentDirectoryName = Path.GetFileName(parentDirectory).ToLower();
|
||||
messages = Helpers.HelperGit.RemoteRemove(parentDirectory, lastRemoteSegment, CancellationToken.None);
|
||||
foreach (string message in messages)
|
||||
logger.LogInformation("{function} => {parentDirectoryName}: [{message}]", nameof(Helpers.HelperGit.RemoteRemove), parentDirectoryName, message);
|
||||
messages = Helpers.HelperGit.RemoteAdd(parentDirectory, remoteToAddName, $"{remoteToAddUrl}{parentDirectoryName}{extension}", CancellationToken.None);
|
||||
foreach (string message in messages)
|
||||
logger.LogInformation("{function} => {parentDirectoryName}: [{message}]", nameof(Helpers.HelperGit.RemoteAdd), parentDirectoryName, message);
|
||||
if (!branchCheck)
|
||||
continue;
|
||||
try
|
||||
{ messages = Helpers.HelperGit.PushBranch(parentDirectory, remoteToAddName, branchName, CancellationToken.None); }
|
||||
catch (Exception)
|
||||
{ messages = new([]); }
|
||||
foreach (string message in messages)
|
||||
logger.LogInformation("{function} => {parentDirectoryName}: [{message}]", nameof(Helpers.HelperGit.PushBranch), parentDirectoryName, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -76,7 +76,9 @@ internal static class HelperDay
|
||||
else if (args[1] == "Day-Helper-2024-06-23")
|
||||
Day.Helper20240623.UpdateSubTasksInMarkdownFiles(logger, args);
|
||||
else if (args[1] == "Day-Helper-2024-06-24")
|
||||
Day.Helper20240624.MoveUpOndDirectory(logger, args);
|
||||
Day.Helper20240624.MoveUpOneDirectory(logger, args);
|
||||
else if (args[1] == "Day-Helper-2024-07-11")
|
||||
Day.Helper20240711.GitRemoteRemove(logger, args);
|
||||
else
|
||||
throw new Exception(appSettings.Company);
|
||||
}
|
||||
|
@ -43,13 +43,10 @@ internal static class HelperGit
|
||||
return result.Output;
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<string> GetOthersModifiedAndDeletedExcludingStandardFiles(string repositoryDirectory, bool usePathCombine, CancellationToken cancellationToken)
|
||||
private static List<string> GetOthersModifiedAndDeletedExcludingStandardFilesAsList(string repositoryDirectory, bool usePathCombine, CancellationToken cancellationToken)
|
||||
{
|
||||
List<string> results = [];
|
||||
string checkDirectory = Path.Combine(repositoryDirectory, ".git");
|
||||
if (Directory.Exists(checkDirectory))
|
||||
{
|
||||
Task<string> task = RunAsync($"ls-files --others --modified --deleted --exclude-standard", repositoryDirectory, cancellationToken);
|
||||
Task<string> task = RunAsync("ls-files --others --modified --deleted --exclude-standard", repositoryDirectory, cancellationToken);
|
||||
task.Wait(cancellationToken);
|
||||
string[] files = task.Result.Split("\r\n");
|
||||
foreach (string file in files)
|
||||
@ -59,8 +56,65 @@ internal static class HelperGit
|
||||
else
|
||||
results.Add(Path.GetFullPath(Path.Combine(repositoryDirectory, file)));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<string> GetOthersModifiedAndDeletedExcludingStandardFiles(string repositoryDirectory, bool usePathCombine, CancellationToken cancellationToken)
|
||||
{
|
||||
List<string> results = [];
|
||||
List<string> relativePathFiles;
|
||||
DirectoryInfo directoryInfo;
|
||||
bool usePathCombineInner = false;
|
||||
string checkDirectory = Path.Combine(repositoryDirectory, ".git");
|
||||
if (Directory.Exists(checkDirectory))
|
||||
results.AddRange(GetOthersModifiedAndDeletedExcludingStandardFilesAsList(repositoryDirectory, usePathCombine, cancellationToken));
|
||||
string[] subdirectories = Directory.GetDirectories(repositoryDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
foreach (string subdirectory in subdirectories)
|
||||
{
|
||||
directoryInfo = new(subdirectory);
|
||||
if (directoryInfo.LinkTarget is null)
|
||||
continue;
|
||||
checkDirectory = Path.Combine(directoryInfo.LinkTarget, ".git");
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
continue;
|
||||
relativePathFiles = GetOthersModifiedAndDeletedExcludingStandardFilesAsList(directoryInfo.LinkTarget, usePathCombineInner, cancellationToken);
|
||||
foreach (string relativePathFile in relativePathFiles)
|
||||
results.Add(Path.GetFullPath(Path.Combine(subdirectory, relativePathFile)));
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<string> RemoteRemove(string repositoryDirectory, string name, CancellationToken cancellationToken)
|
||||
{
|
||||
List<string> results = [];
|
||||
Task<string> task = RunAsync($"remote rm {name}", repositoryDirectory, cancellationToken);
|
||||
task.Wait(cancellationToken);
|
||||
string[] lines = task.Result.Split("\r\n");
|
||||
foreach (string line in lines)
|
||||
results.Add(line);
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<string> RemoteAdd(string repositoryDirectory, string name, string url, CancellationToken cancellationToken)
|
||||
{
|
||||
List<string> results = [];
|
||||
Task<string> task = RunAsync($"remote add {name} {url}", repositoryDirectory, cancellationToken);
|
||||
task.Wait(cancellationToken);
|
||||
string[] lines = task.Result.Split("\r\n");
|
||||
foreach (string line in lines)
|
||||
results.Add(line);
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static ReadOnlyCollection<string> PushBranch(string repositoryDirectory, string remote, string name, CancellationToken cancellationToken)
|
||||
{
|
||||
List<string> results = [];
|
||||
Task<string> task = RunAsync($"push {remote} {name}", repositoryDirectory, cancellationToken);
|
||||
task.Wait(cancellationToken);
|
||||
string[] lines = task.Result.Split("\r\n");
|
||||
foreach (string line in lines)
|
||||
results.Add(line);
|
||||
return new(results);
|
||||
}
|
||||
|
||||
}
|
@ -160,7 +160,7 @@ internal static partial class HelperKanbanMetadata
|
||||
results.Add(lines[i]);
|
||||
}
|
||||
}
|
||||
results.Add($"status: \"{record.GroupCount}-{record.Group}\"");
|
||||
results.Add($"status: {record.GroupCount}-{record.Group}");
|
||||
results.Add("```");
|
||||
results.Add(string.Empty);
|
||||
}
|
||||
@ -201,7 +201,7 @@ internal static partial class HelperKanbanMetadata
|
||||
(lines, lineNumber) = HelperMarkdown.GetStatusAndFrontMatterYamlEndLineNumbers(record.FileInfo);
|
||||
if (lines.Count == 0)
|
||||
continue;
|
||||
statusLine = $"status: \"{record.GroupCount}-{record.Group}\"";
|
||||
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;
|
||||
if (lineNumber.FrontMatterYamlEnd is null)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user