fix(migrations): preserve SHA-256 pull request commit IDs (#39343)

* Fixes #39339

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
breken
2026-09-19 12:41:41 +00:00
committed by GitHub
co-authored by wxiaoguang
parent 2a3d047339
commit cc34c26172
17 changed files with 105 additions and 128 deletions
+3 -3
View File
@@ -849,7 +849,7 @@ func getRefNameLegacy(ctx *Base, repo *Repository, reqPath, extraRef string) (re
if refName := getRefName(ctx, repo, reqRefPath, git.RefTypeTag); refName != "" {
return refName, git.RefTypeTag, false
}
if git.IsStringLikelyCommitID(git.ObjectFormatFromName(repo.Repository.ObjectFormatName), reqRefPathParts[0]) {
if git.IsStringValidObjectID(git.ObjectFormatFromName(repo.Repository.ObjectFormatName), reqRefPathParts[0]) {
// FIXME: this logic is different from other types. Ideally, it should also try to GetCommit to check if it exists
repo.TreePath = strings.Join(reqRefPathParts[1:], "/")
return reqRefPathParts[0], git.RefTypeCommit, false
@@ -900,7 +900,7 @@ func getRefName(ctx *Base, repo *Repository, path string, refType git.RefType) s
})
case git.RefTypeCommit:
parts := strings.Split(path, "/")
if git.IsStringLikelyCommitID(repo.GetObjectFormat(), parts[0], 7) {
if git.IsStringValidObjectID(repo.GetObjectFormat(), parts[0], 7) {
// FIXME: this logic is different from other types. Ideally, it should also try to GetCommit to check if it exists
repo.TreePath = strings.Join(parts[1:], "/")
return parts[0]
@@ -1032,7 +1032,7 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
return
}
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
} else if git.IsStringLikelyCommitID(ctx.Repo.GetObjectFormat(), refShortName, 7) {
} else if git.IsStringValidObjectID(ctx.Repo.GetObjectFormat(), refShortName, 7) {
ctx.Repo.RefFullName = git.RefNameFromCommit(refShortName)
ctx.Repo.CommitID = refShortName