From 661e10dd0ad9d0259a051228f8272d5d15283bd4 Mon Sep 17 00:00:00 2001 From: bennibyx Date: Wed, 14 Oct 2026 22:58:08 +0530 Subject: [PATCH 1/3] Fix annotated tag commit SHA resolution --- src/PinAction/Program.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/PinAction/Program.cs b/src/PinAction/Program.cs index d45f42b..d6b5cf8 100644 --- a/src/PinAction/Program.cs +++ b/src/PinAction/Program.cs @@ -156,9 +156,27 @@ private static bool PinActionHash(string path) try { // 获取该版本的 git commit hash - Reference reference = GitHubClient.Git.Reference.Get(repo.Split('/')[0], repo.Split('/')[1], $"{refType}/{tag}").Result; - hash = reference.Object.Sha; + string owner = repo.Split('/')[0]; + string repository = repo.Split('/')[1]; + + Reference reference = GitHubClient.Git.Reference.Get(owner, repository, $"{refType}/{tag}").Result; + TagObject gitObject = reference.Object; + + while (gitObject.Type.Value == TaggedType.Tag) + { + GitTag gitTag = GitHubClient.Git.Tag.Get(owner, repository, gitObject.Sha).Result; + gitObject = gitTag.Object; + } + + if (gitObject.Type.Value != TaggedType.Commit) + { + AnsiConsole.MarkupLineInterpolated( + $"[red]Reference '{tag}' does not resolve to a commit.[/]"); + continue; + } + + hash = gitObject.Sha; PinedActions.TryAdd($"{repo}@{tag}", hash); break; } From ea66ccdb888332af4c6a26cb28431246fdca1429 Mon Sep 17 00:00:00 2001 From: bennibyx Date: Thu, 15 Oct 2026 18:58:32 +0530 Subject: [PATCH 2/3] Localize reference-not-commit error --- src/PinAction/Program.cs | 2 +- src/PinAction/Resources/Strings.Designer.cs | 6 ++++++ src/PinAction/Resources/Strings.resx | 4 ++++ src/PinAction/Resources/Strings.zh-CN.resx | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/PinAction/Program.cs b/src/PinAction/Program.cs index d6b5cf8..37eeed4 100644 --- a/src/PinAction/Program.cs +++ b/src/PinAction/Program.cs @@ -172,7 +172,7 @@ private static bool PinActionHash(string path) if (gitObject.Type.Value != TaggedType.Commit) { AnsiConsole.MarkupLineInterpolated( - $"[red]Reference '{tag}' does not resolve to a commit.[/]"); + $"[red]{string.Format(Strings.ErrorReferenceNotCommit, Markup.Escape(tag))}[/]"); continue; } diff --git a/src/PinAction/Resources/Strings.Designer.cs b/src/PinAction/Resources/Strings.Designer.cs index 9d2d43d..2f85fb7 100644 --- a/src/PinAction/Resources/Strings.Designer.cs +++ b/src/PinAction/Resources/Strings.Designer.cs @@ -113,6 +113,12 @@ internal static string ErrorTagNotFound { return ResourceManager.GetString("ErrorTagNotFound", resourceCulture); } } + + internal static string ErrorReferenceNotCommit { + get { + return ResourceManager.GetString("ErrorReferenceNotCommit", resourceCulture); + } + } /// /// 查找类似 Found [blue]{1}[/] in [blue]{0}[/] 的本地化字符串。 diff --git a/src/PinAction/Resources/Strings.resx b/src/PinAction/Resources/Strings.resx index 772499f..b4453d2 100644 --- a/src/PinAction/Resources/Strings.resx +++ b/src/PinAction/Resources/Strings.resx @@ -137,6 +137,10 @@ The repository {0} does not exist. 存储库不存在的错误信息 + + Reference '{0}' does not resolve to a commit. + Error shown when a tag or reference does not point to a commit. + Tag {0} not found, maybe this is a branch reference? I'll give it a try... 未找到标签引用的提示信息 diff --git a/src/PinAction/Resources/Strings.zh-CN.resx b/src/PinAction/Resources/Strings.zh-CN.resx index 408b36e..8e828d7 100644 --- a/src/PinAction/Resources/Strings.zh-CN.resx +++ b/src/PinAction/Resources/Strings.zh-CN.resx @@ -132,6 +132,9 @@ 存储库 {0} 不存在。 + + 引用 '{0}' 无法解析为提交。 + 未找到标签 {0},也许这是分支引用?我试试看... From a4fc8febed7c102abb3627e437acd90755a29566 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: Sat, 24 Oct 2026 11:05:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 tag 引用没有解析为 commit 时就直接 return false; 并提示“跳过 xxx@yyy”。 --- src/PinAction/Program.cs | 5 ++--- src/PinAction/Resources/Strings.Designer.cs | 17 ++++++++++------- src/PinAction/Resources/Strings.resx | 6 +++--- src/PinAction/Resources/Strings.zh-CN.resx | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/PinAction/Program.cs b/src/PinAction/Program.cs index 412addb..e5031db 100644 --- a/src/PinAction/Program.cs +++ b/src/PinAction/Program.cs @@ -171,9 +171,8 @@ internal static bool PinActionHash(string path) if (gitObject.Type.Value != TaggedType.Commit) { - AnsiConsole.MarkupLineInterpolated( - $"[red]{string.Format(Strings.ErrorReferenceNotCommit, Markup.Escape(tag))}[/]"); - continue; + AnsiConsole.MarkupLine($"{Print.MSHead.Warning} [red]{Markup.Escape(string.Format(Strings.ErrorReferenceNotCommit, tag, $"{repo}@{tag}"))}[/]"); + return false; } hash = gitObject.Sha; diff --git a/src/PinAction/Resources/Strings.Designer.cs b/src/PinAction/Resources/Strings.Designer.cs index 2f85fb7..630a3db 100644 --- a/src/PinAction/Resources/Strings.Designer.cs +++ b/src/PinAction/Resources/Strings.Designer.cs @@ -96,6 +96,15 @@ internal static string ErrorRateLimitExceeded { } } + /// + /// 查找类似 The reference {0} did not resolve to a commit; skipping {1}. 的本地化字符串。 + /// + internal static string ErrorReferenceNotCommit { + get { + return ResourceManager.GetString("ErrorReferenceNotCommit", resourceCulture); + } + } + /// /// 查找类似 The repository {0} does not exist. 的本地化字符串。 /// @@ -113,12 +122,6 @@ internal static string ErrorTagNotFound { return ResourceManager.GetString("ErrorTagNotFound", resourceCulture); } } - - internal static string ErrorReferenceNotCommit { - get { - return ResourceManager.GetString("ErrorReferenceNotCommit", resourceCulture); - } - } /// /// 查找类似 Found [blue]{1}[/] in [blue]{0}[/] 的本地化字符串。 @@ -202,7 +205,7 @@ internal static string License { } /// - /// 查找类似 {0} doesn't look like a repository format; skip {1} 的本地化字符串。 + /// 查找类似 {0} doesn't look like a repository format; skipping {1} 的本地化字符串。 /// internal static string NotARepository { get { diff --git a/src/PinAction/Resources/Strings.resx b/src/PinAction/Resources/Strings.resx index b4453d2..40a4a20 100644 --- a/src/PinAction/Resources/Strings.resx +++ b/src/PinAction/Resources/Strings.resx @@ -138,8 +138,8 @@ 存储库不存在的错误信息 - Reference '{0}' does not resolve to a commit. - Error shown when a tag or reference does not point to a commit. + The reference {0} did not resolve to a commit; skipping {1}. + 在引用最终不是指向提交时显示的错误信息 Tag {0} not found, maybe this is a branch reference? I'll give it a try... @@ -182,7 +182,7 @@ 许可(证) - {0} doesn't look like a repository format; skip {1} + {0} doesn't look like a repository format; skipping {1} 看起来不像存储库的 diff --git a/src/PinAction/Resources/Strings.zh-CN.resx b/src/PinAction/Resources/Strings.zh-CN.resx index 8e828d7..24634eb 100644 --- a/src/PinAction/Resources/Strings.zh-CN.resx +++ b/src/PinAction/Resources/Strings.zh-CN.resx @@ -133,7 +133,7 @@ 存储库 {0} 不存在。 - 引用 '{0}' 无法解析为提交。 + 引用 {0} 未能解析为提交,跳过 {1}。 未找到标签 {0},也许这是分支引用?我试试看...