Add io.Closer guidelines (#29387)

Co-authored-by: Yarden Shoham <git@yardenshoham.com>
This commit is contained in:
KN4CK3R 2024-02-25 14:05:23 +01:00 committed by GitHub
parent 0676bf52f9
commit ad0a34b492
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 16 additions and 9 deletions

View file

@ -88,16 +88,17 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
}
// Close this repository, in particular close the underlying gogitStorage if this is not nil
func (repo *Repository) Close() (err error) {
func (repo *Repository) Close() error {
if repo == nil || repo.gogitStorage == nil {
return
return nil
}
if err := repo.gogitStorage.Close(); err != nil {
gitealog.Error("Error closing storage: %v", err)
}
repo.gogitStorage = nil
repo.LastCommitCache = nil
repo.tagCache = nil
return
return nil
}
// GoGitRepo gets the go-git repo representation