From 8f93842b9a2b2f709508310043259be01f132207 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 14 Nov 2024 10:19:40 +0100 Subject: [PATCH 1/5] add hint to solve git errors with a synced repo --- nf_core/synced_repo.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nf_core/synced_repo.py b/nf_core/synced_repo.py index e2a76ccaeb..e25641b815 100644 --- a/nf_core/synced_repo.py +++ b/nf_core/synced_repo.py @@ -260,6 +260,11 @@ def checkout(self, commit): log.debug(f"Overwriting local changes in '{self.local_repo_dir}'") self.repo.git.checkout(self.branch, force=True) else: + log.error( + f"Could not check out commit '{commit}' in '{self.remote_url}'.\n" + "To solve this, you can try to remove the cloned rempository and run the command again." + f"This repository is tipically found at `~/.config/nfcore/{self.local_repo_dir}`" + ) raise e def component_exists(self, component_name, component_type, checkout=True, commit=None): From 0396f405f0ba7e7e506066ed77377dccaa71b064 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Thu, 14 Nov 2024 09:43:17 +0000 Subject: [PATCH 2/5] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a449cf681f..c6a5e9fb43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - handle new schema structure in `nf-core pipelines create-params-file` ([#3276](https://github.com/nf-core/tools/pull/3276)) - Update Gitpod image to use Miniforge instead of Miniconda([#3274](https://github.com/nf-core/tools/pull/3274)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.7.3 ([#3275](https://github.com/nf-core/tools/pull/3275)) +- Add hint to solve git errors with a synced repo ([#3279](https://github.com/nf-core/tools/pull/3279)) ## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11] From bdce677c32d8406a6a0056b06b8290b1f958a8dc Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 14 Nov 2024 11:50:49 +0100 Subject: [PATCH 3/5] write proper path and raise a UserWarning to avoid printing the error trace --- nf_core/synced_repo.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/nf_core/synced_repo.py b/nf_core/synced_repo.py index e25641b815..190a3f671f 100644 --- a/nf_core/synced_repo.py +++ b/nf_core/synced_repo.py @@ -261,11 +261,11 @@ def checkout(self, commit): self.repo.git.checkout(self.branch, force=True) else: log.error( - f"Could not check out commit '{commit}' in '{self.remote_url}'.\n" - "To solve this, you can try to remove the cloned rempository and run the command again." - f"This repository is tipically found at `~/.config/nfcore/{self.local_repo_dir}`" + f"You found a git error: {e}\n" + "To solve this, you can try to remove the cloned rempository and run the command again.\n" + f"This repository is typically found at `{self.local_repo_dir}`" ) - raise e + raise UserWarning def component_exists(self, component_name, component_type, checkout=True, commit=None): """ @@ -400,8 +400,16 @@ def get_component_git_log( old_component_path = Path("modules", component_name) commits_old_iter = self.repo.iter_commits(max_count=depth, paths=old_component_path) - commits_old = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_old_iter] - commits_new = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_new_iter] + try: + commits_old = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_old_iter] + commits_new = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_new_iter] + except git.GitCommandError as e: + log.error( + f"You found a git error: {e}\n" + "To solve this, you can try to remove the cloned rempository and run the command again.\n" + f"This repository is typically found at `{self.local_repo_dir}`" + ) + raise UserWarning commits = iter(commits_new + commits_old) return commits From 30c37451449ed7354eb93ebfeaa79b3045daa116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Thu, 14 Nov 2024 13:04:36 +0100 Subject: [PATCH 4/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Hörtenhuber --- nf_core/synced_repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nf_core/synced_repo.py b/nf_core/synced_repo.py index 190a3f671f..0532774630 100644 --- a/nf_core/synced_repo.py +++ b/nf_core/synced_repo.py @@ -261,7 +261,7 @@ def checkout(self, commit): self.repo.git.checkout(self.branch, force=True) else: log.error( - f"You found a git error: {e}\n" + f"Git error: {e}\n" "To solve this, you can try to remove the cloned rempository and run the command again.\n" f"This repository is typically found at `{self.local_repo_dir}`" ) @@ -405,7 +405,7 @@ def get_component_git_log( commits_new = [{"git_sha": commit.hexsha, "trunc_message": commit.message} for commit in commits_new_iter] except git.GitCommandError as e: log.error( - f"You found a git error: {e}\n" + f"Git error: {e}\n" "To solve this, you can try to remove the cloned rempository and run the command again.\n" f"This repository is typically found at `{self.local_repo_dir}`" ) From db11da579faf927e044616d6502ef3679c70b094 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 14 Nov 2024 14:20:41 +0100 Subject: [PATCH 5/5] remove logging git error from wrong place --- nf_core/synced_repo.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nf_core/synced_repo.py b/nf_core/synced_repo.py index 0532774630..dd61b72a2b 100644 --- a/nf_core/synced_repo.py +++ b/nf_core/synced_repo.py @@ -260,12 +260,7 @@ def checkout(self, commit): log.debug(f"Overwriting local changes in '{self.local_repo_dir}'") self.repo.git.checkout(self.branch, force=True) else: - log.error( - f"Git error: {e}\n" - "To solve this, you can try to remove the cloned rempository and run the command again.\n" - f"This repository is typically found at `{self.local_repo_dir}`" - ) - raise UserWarning + raise e def component_exists(self, component_name, component_type, checkout=True, commit=None): """