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

Handle dirty local module repos by force checkout of commits and branches if needed #2734

Merged
merged 11 commits into from
Feb 13, 2024

Conversation

gregorysprenger
Copy link
Contributor

@gregorysprenger gregorysprenger commented Feb 6, 2024

Use a try/except block to catch GitCommandError errors when performing git checkout, where changes may need to be stashed or force the checkout. This should solve issues similar to #2656 and the need to use rm -rf ~/.config/nfcore/nf-core/modules/ where the following error is observed:

GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git checkout master
stderr: 'error: Your local changes to the following files would be overwritten by checkout:

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (d7610a1) 73.53% compared to head (3e95d02) 73.61%.

❗ Current head 3e95d02 differs from pull request most recent head 77aa1cb. Consider uploading reports for the commit 77aa1cb to get more accurate results

Files Patch % Lines
nf_core/synced_repo.py 50.00% 7 Missing ⚠️
Additional details and impacted files

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mashehu
Copy link
Contributor

mashehu commented Feb 7, 2024

Thanks, that's a great addition, just tried to make it a bit more fail-safe.

@mirpedrol: do you think we should ask first before we overwrite changes?

@mashehu mashehu changed the title Force checkout of commits and branches if needed Handle dirty local module repos by force checkout of commits and branches if needed Feb 7, 2024
@mashehu
Copy link
Contributor

mashehu commented Feb 7, 2024

@nf-core-bot changelog

@gregorysprenger
Copy link
Contributor Author

@mashehu Awesome, thanks! If you all would rather stash the changes and re-checkout, I'm more than happy to make those changes.

@mashehu
Copy link
Contributor

mashehu commented Feb 8, 2024

A dirty local module repo is usually the result of an error during an installation/update, so nothing could actively be lost, maybe I am just a bit too paranoid... this is probably the better solution, instead of dragging an installation error along

@mirpedrol
Copy link
Member

Looks good! but I agree with @mashehu I would prefer to first ask the user if they want to continue and delete changes.

@mashehu
Copy link
Contributor

mashehu commented Feb 8, 2024

after a quick thought, new idea: because we use this function also in other contexts, we should check that we are in the modules repo in the if clause and then do a force checkout with a prompt and otherwise raise an errror to be on the save side

@mashehu mashehu merged commit aa2c14c into nf-core:dev Feb 13, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants