-
Notifications
You must be signed in to change notification settings - Fork 95
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
prohibit pushes if nbstripout is not installed #101
Comments
I think what you want is a pre-commit hook to already prevent commits when You could ask your developers to run the following in the root of their repositories (only tested on Linux):
|
Thanks! This almost fixed the issue, except that it won't block the developers to push changes withoug being the notebooks being cleaned. I didn't see the issue when I was posted the question. So, the
I re-read the documentation, and I though that the (manual-filter-installation)[https://github.com/kynan/nbstripout#manual-filter-installation] could help me there but I seem to be confusing what it dows. I would also like to add this |
Is there a way of making sure that the ipynb is clean ("nbstripped"). At least, I can prevent commits if this is not the case. |
I modified the script.
However, this is not yet perfect. Somebody can still circumvent the nbstripout by installing nbstripout just before the commit.
However, the above feels almost intentional. Unfortunately, hooks are not designed to be part of the repository. |
As you already found out there is no way to make git activate a hook after cloning the repository (this is by design to prevent malicious code from being executed). I think you want to prevent accidental rather than intentional cases of nbstripout not being installed, so I don't the last point is much of a concern (also because you can simply run There are 2 pull requests adding support for pre-commit.com, however their intent is different from yours I think. |
@robertour friendly ping, have you been able to resolve this to your satisfaction? |
I think so, it has done the trick. I would just add that it is also a good idea to install this at a git global level. I share some instructions that I give to the programmers.
This tells git to copy everything in ~/.git-templates to your per-project .git/ directory when you run git init 2.Create a directory to hold the global hooks:
|
Is there any way to configure github (with hooks maybe?) so that pushes are impossible when nbstripout is not installed.
I struggle with developers that forget to
install
nbstripout afteruninstall
it. Sometimes, we are forced to do uninstall because of this bug (#65); which seems to be very difficult to fix.So, an alternative to avoid dirty jupyter notebooks would be to avoid pushes when nbstripout is not installed. I think hooks would be a way to go, but I have never used one.
The text was updated successfully, but these errors were encountered: