Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Add hint to solve git errors with a synced repo #3279

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
19 changes: 16 additions & 3 deletions nf_core/synced_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ def checkout(self, commit):
log.debug(f"Overwriting local changes in '{self.local_repo_dir}'")
self.repo.git.checkout(self.branch, force=True)
else:
raise e
log.error(
f"You found a git error: {e}\n"
mirpedrol marked this conversation as resolved.
Show resolved Hide resolved
"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

def component_exists(self, component_name, component_type, checkout=True, commit=None):
"""
Expand Down Expand Up @@ -395,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"
mirpedrol marked this conversation as resolved.
Show resolved Hide resolved
"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
Expand Down
Loading