diff --git a/src/PinAction/Program.cs b/src/PinAction/Program.cs
index 232ab8f..e5031db 100644
--- a/src/PinAction/Program.cs
+++ b/src/PinAction/Program.cs
@@ -156,9 +156,26 @@ internal 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.MarkupLine($"{Print.MSHead.Warning} [red]{Markup.Escape(string.Format(Strings.ErrorReferenceNotCommit, tag, $"{repo}@{tag}"))}[/]");
+ return false;
+ }
+
+ hash = gitObject.Sha;
PinedActions.TryAdd($"{repo}@{tag}", hash);
break;
}
diff --git a/src/PinAction/Resources/Strings.Designer.cs b/src/PinAction/Resources/Strings.Designer.cs
index 9d2d43d..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. 的本地化字符串。
///
@@ -196,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 772499f..40a4a20 100644
--- a/src/PinAction/Resources/Strings.resx
+++ b/src/PinAction/Resources/Strings.resx
@@ -137,6 +137,10 @@
The repository {0} does not exist.
存储库不存在的错误信息
+
+ 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...
未找到标签引用的提示信息
@@ -178,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 408b36e..24634eb 100644
--- a/src/PinAction/Resources/Strings.zh-CN.resx
+++ b/src/PinAction/Resources/Strings.zh-CN.resx
@@ -132,6 +132,9 @@
存储库 {0} 不存在。
+
+ 引用 {0} 未能解析为提交,跳过 {1}。
+
未找到标签 {0},也许这是分支引用?我试试看...