Skip to content

Commit

Permalink
fix: closing git resources to fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
wufe committed Dec 5, 2023
1 parent 499b0d5 commit 57eb28a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/versioning/repository-fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func (fetcher *RepositoryFetcherImpl) Fetch(baseFolder string, disableTerminalPr
if err != nil {
errors = append(errors, &FetcherError{err, false})
}
defer branches.Close()

refPrefix := "refs/heads/"
branches.ForEach(func(ref *plumbing.Reference) error {
refName := ref.Name().String()
Expand Down Expand Up @@ -128,6 +130,7 @@ func (fetcher *RepositoryFetcherImpl) Fetch(baseFolder string, disableTerminalPr
errors = append(errors, &FetcherError{err, false})
return nil, errors
}
defer tags.Close()

tagPrefix := "refs/tags/"
err = tags.ForEach(func(ref *plumbing.Reference) error {
Expand Down Expand Up @@ -171,6 +174,7 @@ func (fetcher *RepositoryFetcherImpl) Fetch(baseFolder string, disableTerminalPr
errors = append(errors, &FetcherError{err, false})
return nil, errors
}
defer tagObjects.Close()

err = tagObjects.ForEach(func(ref *object.Tag) error {
refName := ref.Name
Expand Down Expand Up @@ -215,6 +219,7 @@ func (fetcher *RepositoryFetcherImpl) Fetch(baseFolder string, disableTerminalPr
errors = append(errors, &FetcherError{err, false})
return nil, errors
}
defer logs.Close()

err = logs.ForEach(func(commit *object.Commit) error {
commitHash := commit.Hash.String()
Expand Down
1 change: 1 addition & 0 deletions third_party/polo-pro
Submodule polo-pro added at dc8c72

0 comments on commit 57eb28a

Please sign in to comment.