Skip to content

Commit

Permalink
open_repo_closing is reserved to existing git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Nov 25, 2022
1 parent 5380cd7 commit 7bad3ed
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions qgis_deployment_toolbelt/profiles/remote_git_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ def clone_or_pull(self, local_path: Union[str, Path]) -> Repo:

# clone
if local_path.exists() and not self.is_local_path_git_repository(local_path):
logger.info(f"Cloning repository {self.url} to {local_path}")
try:
return self._clone(local_path=local_path)
except Exception as err:
logger.error(
f"Error cloning the remote repository{self.url} "
f"(branch {self.branch}) to {local_path}."
f"Error cloning the remote repository {self.url} "
f"(branch {self.branch}) to {local_path}. "
f"Trace: {err}."
)
raise err
Expand Down Expand Up @@ -144,18 +143,17 @@ def _clone(self, local_path: Union[str, Path]) -> Repo:
# clone
if local_path.exists() and not self.is_local_path_git_repository(local_path):
logger.info(f"Cloning repository {self.url} to {local_path}")
with porcelain.open_repo_closing(str(local_path.resolve())) as local_repo:
repo = porcelain.clone(
source=self.url,
target=local_repo,
branch=self.branch,
depth=5,
)
gobj = local_repo.get_object(repo.head())
logger.debug(
f"Latest commit cloned: {gobj.sha().hexdigest()} by {gobj.author}"
f" at {gobj.commit_time}"
)
local_repo = porcelain.clone(
source=self.url,
target=str(local_path.resolve()),
branch=self.branch,
depth=5,
)
gobj = local_repo.get_object(local_repo.head())
logger.debug(
f"Latest commit cloned: {gobj.sha().hexdigest()} by {gobj.author}"
f" at {gobj.commit_time}"
)
return local_repo

def _fetch(self, local_path: Union[str, Path]) -> Repo:
Expand Down

0 comments on commit 7bad3ed

Please sign in to comment.