Skip to content

Commit bdce677

Browse files
committed
write proper path and raise a UserWarning to avoid printing the error trace
1 parent 0396f40 commit bdce677

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

nf_core/synced_repo.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def checkout(self, commit):
261261
self.repo.git.checkout(self.branch, force=True)
262262
else:
263263
log.error(
264-
f"Could not check out commit '{commit}' in '{self.remote_url}'.\n"
265-
"To solve this, you can try to remove the cloned rempository and run the command again."
266-
f"This repository is tipically found at `~/.config/nfcore/{self.local_repo_dir}`"
264+
f"You found a git error: {e}\n"
265+
"To solve this, you can try to remove the cloned rempository and run the command again.\n"
266+
f"This repository is typically found at `{self.local_repo_dir}`"
267267
)
268-
raise e
268+
raise UserWarning
269269

270270
def component_exists(self, component_name, component_type, checkout=True, commit=None):
271271
"""
@@ -400,8 +400,16 @@ def get_component_git_log(
400400
old_component_path = Path("modules", component_name)
401401
commits_old_iter = self.repo.iter_commits(max_count=depth, paths=old_component_path)
402402

403-
commits_old = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_old_iter]
404-
commits_new = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_new_iter]
403+
try:
404+
commits_old = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_old_iter]
405+
commits_new = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_new_iter]
406+
except git.GitCommandError as e:
407+
log.error(
408+
f"You found a git error: {e}\n"
409+
"To solve this, you can try to remove the cloned rempository and run the command again.\n"
410+
f"This repository is typically found at `{self.local_repo_dir}`"
411+
)
412+
raise UserWarning
405413
commits = iter(commits_new + commits_old)
406414

407415
return commits

0 commit comments

Comments
 (0)