Backport #32705 by @Zettat123Fix#32335
When we call `GetRefCommitID` and the reference is already a commit ID,
the `GetRefCommitID` with go-git will return a `NotExist` error. This PR
improves the `GetRefCommitID` for go-git. If the input is already a
commit ID, it will be returned directly.
Co-authored-by: Zettat123 <zettat123@gmail.com>