refactor(RepoManager): if no branch is given, no checkout is done

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2024-03-24 00:02:10 +01:00
parent 341ecb325c
commit 7104eb078f

View File

@@ -24,7 +24,7 @@ class RepoManager:
branch: str = None, branch: str = None,
): ):
self._repo = repo self._repo = repo
self._branch = branch if branch is not None else "master" self._branch = branch
self._method = self._get_method() self._method = self._get_method()
self._target_dir = target_dir self._target_dir = target_dir
@@ -110,7 +110,7 @@ class RepoManager:
if Path(self.target_dir).exists(): if Path(self.target_dir).exists():
question = f"'{self.target_dir}' already exists. Overwrite?" question = f"'{self.target_dir}' already exists. Overwrite?"
if not get_confirm(question, default_choice=False): if not get_confirm(question, default_choice=False):
Logger.print_info("Skipping re-clone of repository.") Logger.print_info("Skip cloning of repository ...")
return return
shutil.rmtree(self.target_dir) shutil.rmtree(self.target_dir)
@@ -145,6 +145,9 @@ class RepoManager:
raise raise
def _checkout(self): def _checkout(self):
if self.branch is None:
return
try: try:
command = ["git", "checkout", f"{self.branch}"] command = ["git", "checkout", f"{self.branch}"]
subprocess.run(command, cwd=self.target_dir, check=True) subprocess.run(command, cwd=self.target_dir, check=True)