Fix IsObjectExist with gogit (#31790) (#31806)

Backport #31790 by @wolfogre

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.

Co-authored-by: Jason Song <i@wolfogre.com>
(cherry picked from commit 144648a4afdd93d534875a86c50ec61c860878f3)
This commit is contained in:
Giteabot 2024-08-09 15:43:23 +08:00 committed by Earl Warren
parent 3a18717c6b
commit 3e091b9bac
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 126 additions and 16 deletions

View file

@ -1210,7 +1210,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
}