From c6af3ba93ab9881dece9cba56b7e2ac91791f8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B8=AD=E9=B8=AD=E3=80=8C=E3=82=AB=E3=83=A2=E3=80=8D?= <89643991+DuckDuckStudio@users.noreply.github.com> Date: Sun, 5 Apr 2026 08:05:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore(deps):=20=E6=8F=90=E5=8D=87=20DuckStu?= =?UTF-8?q?dio.CatFood=20=E7=89=88=E6=9C=AC=EF=BC=8C=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20Spectre.Console=20=E4=BD=9C=E4=B8=BA=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DuckStudio.CatFood 2.0.0.1 曾依赖 Spectre.Console,但版本 2.0.0.2 起只依赖 Spectre.Console.Ansi 而 PinAction 需要依赖 Spectre.Console 来输出表格 --- PinAction/PinAction.csproj | 3 ++- PinAction/Program.cs | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/PinAction/PinAction.csproj b/PinAction/PinAction.csproj index 9d615ca..9ecb7f4 100644 --- a/PinAction/PinAction.csproj +++ b/PinAction/PinAction.csproj @@ -25,8 +25,9 @@ - + + diff --git a/PinAction/Program.cs b/PinAction/Program.cs index ee2398c..d0d12aa 100644 --- a/PinAction/Program.cs +++ b/PinAction/Program.cs @@ -1,7 +1,6 @@ using Octokit; using Spectre.Console; using PinAction.Resources; -using System.Globalization; using DuckStudio.CatFood.Functions; using System.Collections.Concurrent; using System.Text.RegularExpressions; @@ -48,9 +47,9 @@ static int Main(string[] args) case "--version": case "--ver": case "-v": - AnsiConsole.MarkupLine($"PinAction {Strings.Version} [green]develop[/] by [link=https://duckduckstudio.github.io/yazicbs.github.io/]鸭鸭「カモ」[/]"); + Console.MarkupLine($"PinAction {Strings.Version} [green]develop[/] by [link=https://duckduckstudio.github.io/yazicbs.github.io/]鸭鸭「カモ」[/]"); Console.WriteLine(); - AnsiConsole.MarkupLine(Strings.HelpVer2License); + Console.MarkupLine(Strings.HelpVer2License); return 0; case "license": case "--license": @@ -62,7 +61,7 @@ static int Main(string[] args) table.AddRow("Octokit", "[link=https://github.com/octokit/octokit.net/blob/main/LICENSE.txt]MIT License[/]"); table.AddRow("DuckStudio.CatFood", "[link=https://github.com/DuckDuckStudio/DuckStudio.CatFood/blob/main/LICENSE]Apache License 2.0[/]"); table.AddRow("Spectre.Console", "[link=https://github.com/spectreconsole/spectre.console/blob/main/LICENSE.md]MIT License[/]"); - AnsiConsole.Write(table); + Console.Write(table); return 0; } } @@ -94,7 +93,7 @@ static int Main(string[] args) } else { - AnsiConsole.MarkupLine(CultureInfo.CurrentCulture, $"{Print.MSHead.Error} {string.Format(Strings.ErrorPathNotExist, fullPath)}"); + Console.MarkupLine($"{Print.MSHead.Error} {string.Format(Strings.ErrorPathNotExist, AnsiMarkup.Escape(fullPath))}"); return 3; } } @@ -127,13 +126,13 @@ private static bool PinActionHash(string path) string repo = match.Groups[1].Value; string tag = match.Groups[2].Value; - AnsiConsole.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.FindAction, Path.GetRelativePath(Environment.CurrentDirectory, path), Markup.Escape($"{repo}@{tag}"))}"); + Console.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.FindAction, AnsiMarkup.Escape(Path.GetRelativePath(Environment.CurrentDirectory, path)), AnsiMarkup.Escape($"{repo}@{tag}"))}"); // 在这里你可以定义排除哪些项 // 例如排除以 actions/ 开头的项(actions/*@*) // if (repo.StartsWith("actions/")) // { - // AnsiConsole.MarkupLine($"{Print.MSHead.Warning} 跳过 {repo}@{tag},因为它是官方工作流"); + // Console.MarkupLine($"{Print.MSHead.Warning} 跳过 {AnsiMarkup.Escape($"{repo}@{tag}")},因为它是官方工作流"); // continue; // } @@ -142,13 +141,13 @@ private static bool PinActionHash(string path) // 检查是否已经是哈希值(40个十六进制字符) if (HashRegex().IsMatch(tag)) { - AnsiConsole.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.SkippingAlreadyPinnedHashes, Markup.Escape($"{repo}@{tag}"))}"); + Console.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.SkippingAlreadyPinnedHashes, AnsiMarkup.Escape($"{repo}@{tag}"))}"); continue; } // 检查仓库是否是 owner/repo 的格式 if (repo.Split('/').Length != 2) { - AnsiConsole.MarkupLine($"{Print.MSHead.Warning} {Markup.Escape(repo)} 看起来不像是仓库的格式,跳过 {Markup.Escape($"{repo}@{tag}")}"); + Console.MarkupLine($"{Print.MSHead.Warning} {AnsiMarkup.Escape(repo)} 看起来不像是仓库的格式,跳过 {AnsiMarkup.Escape($"{repo}@{tag}")}"); continue; } @@ -170,7 +169,7 @@ private static bool PinActionHash(string path) } catch (AggregateException ex) when (ex.InnerException != null) { - AnsiConsole.Markup($"{Print.MSHead.Warning} {Strings.ErrorGetHashFailed}"); + Console.Markup($"{Print.MSHead.Warning} {Strings.ErrorGetHashFailed}"); switch (ex.InnerException) { @@ -189,7 +188,7 @@ private static bool PinActionHash(string path) continue; } case Octokit.RateLimitExceededException: - AnsiConsole.MarkupLine($"[yellow]{Strings.ErrorRateLimitExceeded}[/]"); + Console.MarkupLine($"[yellow]{Strings.ErrorRateLimitExceeded}[/]"); return false; default: AnsiConsole.MarkupLineInterpolated($"[red]{ex.InnerException.Message}[/]"); @@ -201,7 +200,7 @@ private static bool PinActionHash(string path) #if DEBUG else { - AnsiConsole.MarkupLine($"{Print.MSHead.Debug} 读取缓存 {Markup.Escape($"{repo}@{hash}")} # {Markup.Escape(tag)}"); + Console.MarkupLine($"{Print.MSHead.Debug} 读取缓存 {AnsiMarkup.Escape($"{repo}@{hash}")} # {AnsiMarkup.Escape(tag)}"); } #endif @@ -220,7 +219,7 @@ private static bool PinActionHash(string path) } } - AnsiConsole.MarkupLine($"{Print.MSHead.Success} {Strings.Pinned} {Markup.Escape($"{repo}@{hash}")} # {Markup.Escape(tag)}"); + Console.MarkupLine($"{Print.MSHead.Success} {Strings.Pinned} {AnsiMarkup.Escape($"{repo}@{hash}")} # {AnsiMarkup.Escape(tag)}"); } } } From f1f846a756ddcccc59cecfdf4b451b44aa3afd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B8=AD=E9=B8=AD=E3=80=8C=E3=82=AB=E3=83=A2=E3=80=8D?= <89643991+DuckDuckStudio@users.noreply.github.com> Date: Mon, 6 Apr 2026 14:33:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E6=9B=B4=E6=AD=A3=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PinAction/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PinAction/Program.cs b/PinAction/Program.cs index d0d12aa..bc4f625 100644 --- a/PinAction/Program.cs +++ b/PinAction/Program.cs @@ -61,7 +61,7 @@ static int Main(string[] args) table.AddRow("Octokit", "[link=https://github.com/octokit/octokit.net/blob/main/LICENSE.txt]MIT License[/]"); table.AddRow("DuckStudio.CatFood", "[link=https://github.com/DuckDuckStudio/DuckStudio.CatFood/blob/main/LICENSE]Apache License 2.0[/]"); table.AddRow("Spectre.Console", "[link=https://github.com/spectreconsole/spectre.console/blob/main/LICENSE.md]MIT License[/]"); - Console.Write(table); + AnsiConsole.Write(table); // 不要改成 Console.Write() return 0; } } From 4714a141d614cd03c30bee21dd535790d79f48ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B8=AD=E9=B8=AD=E3=80=8C=E3=82=AB=E3=83=A2=E3=80=8D?= <89643991+DuckDuckStudio@users.noreply.github.com> Date: Mon, 6 Apr 2026 14:38:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?tests:=20=E8=BF=98=E5=8E=9F=20Program.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PinAction/Program.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/PinAction/Program.cs b/PinAction/Program.cs index bc4f625..0dfaf25 100644 --- a/PinAction/Program.cs +++ b/PinAction/Program.cs @@ -47,9 +47,9 @@ static int Main(string[] args) case "--version": case "--ver": case "-v": - Console.MarkupLine($"PinAction {Strings.Version} [green]develop[/] by [link=https://duckduckstudio.github.io/yazicbs.github.io/]鸭鸭「カモ」[/]"); + AnsiConsole.MarkupLine($"PinAction {Strings.Version} [green]develop[/] by [link=https://duckduckstudio.github.io/yazicbs.github.io/]鸭鸭「カモ」[/]"); Console.WriteLine(); - Console.MarkupLine(Strings.HelpVer2License); + AnsiConsole.MarkupLine(Strings.HelpVer2License); return 0; case "license": case "--license": @@ -61,7 +61,7 @@ static int Main(string[] args) table.AddRow("Octokit", "[link=https://github.com/octokit/octokit.net/blob/main/LICENSE.txt]MIT License[/]"); table.AddRow("DuckStudio.CatFood", "[link=https://github.com/DuckDuckStudio/DuckStudio.CatFood/blob/main/LICENSE]Apache License 2.0[/]"); table.AddRow("Spectre.Console", "[link=https://github.com/spectreconsole/spectre.console/blob/main/LICENSE.md]MIT License[/]"); - AnsiConsole.Write(table); // 不要改成 Console.Write() + AnsiConsole.Write(table); return 0; } } @@ -93,7 +93,7 @@ static int Main(string[] args) } else { - Console.MarkupLine($"{Print.MSHead.Error} {string.Format(Strings.ErrorPathNotExist, AnsiMarkup.Escape(fullPath))}"); + AnsiConsole.MarkupLine($"{Print.MSHead.Error} {string.Format(Strings.ErrorPathNotExist, fullPath)}"); return 3; } } @@ -126,13 +126,13 @@ private static bool PinActionHash(string path) string repo = match.Groups[1].Value; string tag = match.Groups[2].Value; - Console.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.FindAction, AnsiMarkup.Escape(Path.GetRelativePath(Environment.CurrentDirectory, path)), AnsiMarkup.Escape($"{repo}@{tag}"))}"); + AnsiConsole.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.FindAction, Path.GetRelativePath(Environment.CurrentDirectory, path), Markup.Escape($"{repo}@{tag}"))}"); // 在这里你可以定义排除哪些项 // 例如排除以 actions/ 开头的项(actions/*@*) // if (repo.StartsWith("actions/")) // { - // Console.MarkupLine($"{Print.MSHead.Warning} 跳过 {AnsiMarkup.Escape($"{repo}@{tag}")},因为它是官方工作流"); + // AnsiConsole.MarkupLine($"{Print.MSHead.Warning} 跳过 {repo}@{tag},因为它是官方工作流"); // continue; // } @@ -141,13 +141,13 @@ private static bool PinActionHash(string path) // 检查是否已经是哈希值(40个十六进制字符) if (HashRegex().IsMatch(tag)) { - Console.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.SkippingAlreadyPinnedHashes, AnsiMarkup.Escape($"{repo}@{tag}"))}"); + AnsiConsole.MarkupLine($"{Print.MSHead.Information} {string.Format(Strings.SkippingAlreadyPinnedHashes, Markup.Escape($"{repo}@{tag}"))}"); continue; } // 检查仓库是否是 owner/repo 的格式 if (repo.Split('/').Length != 2) { - Console.MarkupLine($"{Print.MSHead.Warning} {AnsiMarkup.Escape(repo)} 看起来不像是仓库的格式,跳过 {AnsiMarkup.Escape($"{repo}@{tag}")}"); + AnsiConsole.MarkupLine($"{Print.MSHead.Warning} {Markup.Escape(repo)} 看起来不像是仓库的格式,跳过 {Markup.Escape($"{repo}@{tag}")}"); continue; } @@ -169,7 +169,7 @@ private static bool PinActionHash(string path) } catch (AggregateException ex) when (ex.InnerException != null) { - Console.Markup($"{Print.MSHead.Warning} {Strings.ErrorGetHashFailed}"); + AnsiConsole.Markup($"{Print.MSHead.Warning} {Strings.ErrorGetHashFailed}"); switch (ex.InnerException) { @@ -188,7 +188,7 @@ private static bool PinActionHash(string path) continue; } case Octokit.RateLimitExceededException: - Console.MarkupLine($"[yellow]{Strings.ErrorRateLimitExceeded}[/]"); + AnsiConsole.MarkupLine($"[yellow]{Strings.ErrorRateLimitExceeded}[/]"); return false; default: AnsiConsole.MarkupLineInterpolated($"[red]{ex.InnerException.Message}[/]"); @@ -200,7 +200,7 @@ private static bool PinActionHash(string path) #if DEBUG else { - Console.MarkupLine($"{Print.MSHead.Debug} 读取缓存 {AnsiMarkup.Escape($"{repo}@{hash}")} # {AnsiMarkup.Escape(tag)}"); + AnsiConsole.MarkupLine($"{Print.MSHead.Debug} 读取缓存 {Markup.Escape($"{repo}@{hash}")} # {Markup.Escape(tag)}"); } #endif @@ -219,7 +219,7 @@ private static bool PinActionHash(string path) } } - Console.MarkupLine($"{Print.MSHead.Success} {Strings.Pinned} {AnsiMarkup.Escape($"{repo}@{hash}")} # {AnsiMarkup.Escape(tag)}"); + AnsiConsole.MarkupLine($"{Print.MSHead.Success} {Strings.Pinned} {Markup.Escape($"{repo}@{hash}")} # {Markup.Escape(tag)}"); } } }