Add abstraction layer to check if the repository exists on disk (#33874)

Extract from #28966 

This PR uses `gitrepo.IsRepositoryExist` instead of `util.IsExist` to
detect whether the repository exist in disk. This will move `RepoPath`
detail behind of package `gitrepo` to make it easier to do possible
changes where storing the repositories.

No code change
This commit is contained in:
Lunny Xiao
2025-03-13 20:00:56 -07:00
committed by GitHub
parent 1e7248047c
commit 9c673d066c
6 changed files with 45 additions and 47 deletions

View File

@ -69,3 +69,8 @@ func RepositoryFromRequestContextOrOpen(ctx reqctx.RequestContext, repo Reposito
ctx.SetContextValue(ck, gitRepo)
return gitRepo, nil
}
// IsRepositoryExist returns true if the repository directory exists in the disk
func IsRepositoryExist(ctx context.Context, repo Repository) (bool, error) {
return util.IsExist(repoPath(repo))
}