Fix IsObjectExist with gogit (#31790)

Fix #31271.

When gogit is enabled, `IsObjectExist` calls
`repo.gogitRepo.ResolveRevision`, which is not correct. It's for
checking references not objects, it could work with commit hash since
it's both a valid reference and a commit object, but it doesn't work
with blob objects.

So it causes #31271 because it reports that all blob objects do not
exist.
This commit is contained in:
Jason Song 2024-08-09 10:40:45 +08:00 committed by GitHub
parent 33cc5837a6
commit f4d3120f9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 127 additions and 16 deletions

View file

@ -1144,7 +1144,8 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
})
}
exist = ctx.GitRepo.IsObjectExist(hash)
// Don't use IsObjectExist since it doesn't support short hashs with gogit edition.
exist = ctx.GitRepo.IsReferenceExist(hash)
ctx.ShaExistCache[hash] = exist
}