Skip to content

Commit c774fef

Browse files
authored
improve(repository): fix some files leaking (#665)
2 parents 08486b8 + 672f735 commit c774fef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

qgis_deployment_toolbelt/profiles/profiles_handler_base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _is_local_path_git_repository(
179179
local_path: Path = self.SOURCE_REPOSITORY_PATH_OR_URL
180180

181181
try:
182-
Repo(root=f"{local_path.resolve()}")
182+
porcelain.open_repo_closing(f"{local_path.resolve()}")
183183
return True
184184
except NotGitRepository as err:
185185
if not raise_error:
@@ -253,7 +253,7 @@ def get_active_branch_from_local_repository(
253253
)
254254

255255
return porcelain.active_branch(
256-
repo=Repo(root=f"{local_git_repository_path.resolve()}")
256+
repo=f"{local_git_repository_path.resolve()}"
257257
).decode()
258258

259259
def is_branch_existing_in_repository(
@@ -506,8 +506,8 @@ def _clone(self, local_path: Path) -> Repo:
506506
if self.SOURCE_REPOSITORY_TYPE in ("git_local", "local"):
507507
with porcelain.open_repo_closing(
508508
path_or_repo=self.SOURCE_REPOSITORY_PATH_OR_URL.as_posix()
509-
) as repo_obj:
510-
repo_obj.clone(
509+
) as src_repo_obj:
510+
repo_obj = src_repo_obj.clone(
511511
target_path=f"{local_path.resolve()}",
512512
branch=branch,
513513
mkdir=False,
@@ -529,6 +529,7 @@ def _clone(self, local_path: Path) -> Repo:
529529
f"Latest commit cloned: {gobj.sha().hexdigest()} by {gobj.author}"
530530
f" at {gobj.commit_time}."
531531
)
532+
repo_obj.close()
532533
return repo_obj
533534

534535
@proxies.os_env_proxy

0 commit comments

Comments
 (0)