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

Add --global option to --install to save filter config to global .gitconfig #98

Closed
jraviotta opened this issue May 30, 2019 · 6 comments

Comments

@jraviotta
Copy link
Contributor

Presently, nbstripout --install modifies the repo .git/config. This is less portable than saving the path to nbstripout and the filters in the user's global .gitconfig.

It would be nice to have a command such as:
nbstripout --install --global --atributes .gitattributes that created a .gitattributes file in the current repo but saved the filters and path globally. Then, every repo with the .gitattributes file would be stripped without needing to install nbstripout in every cloned repository.

See conversation #7

@jraviotta
Copy link
Contributor Author

jraviotta commented May 31, 2019

FYI: For the inevitable bug reports that will come from VS Code users, please note the following.

After adding the filters to my global .gitconfig, nbstripout works as expected on mac and from the cli in WSL. However, using the integrated .git UI in Visual Studio Code does not work. The problem appears to be that VS Code is searching for the filters using Windows-style paths rather than the WSL-style paths such as /mnt/c/users/<user>/miniconda3/....

References: VS Code VCS and Git: Support WSL #9502

This solution fixed my problem using the insiders build of VS Code.

This is also helpful.

@consideRatio
Copy link

The system wide git config seems to reside in $(prefix)/etc/gitconfig, and the global in ~/.gitconfig, and the git repo local one within .git/config. For more details see https://git-scm.com/docs/git-config.

So, if we add a --global we may also want to add a --system.

@kynan
Copy link
Owner

kynan commented Jun 30, 2019

I wouldn't want to mess with the system wide config since those files are controlled by your system package manager and whenever those would be changed e.g. when the git-core package is updated you'd end up with a conflict you need to resolve.

On top of that you'd need to run nbstripout with sudo, which is not something I'd advise doing.

kynan added a commit that referenced this issue Jun 30, 2019
Setting this flag writes the filter config to ~/.gitconfig
kynan added a commit that referenced this issue Jun 30, 2019
Also add an overview table of the different configuration options and
document them in the 'Manual filter installation' section.
@kynan
Copy link
Owner

kynan commented Jul 21, 2019

I've added a --global flag for --install/--uninstall which is already released in 0.3.6. Does this fit your needs @jraviotta ?

@jraviotta
Copy link
Contributor Author

Thanks a bunch @kynan . I tested on one of my projects and it worked as I had hoped it would. The table in the documentation is especially helpful.

One side effect to note however:
When I executed nbstripout --uninstall --global --attributes=.gitattributes, the entry in ~/.gitconfg and .gitattributes were deleted as expected. But I had some additional settings configured that were not re-installed with nbstripout --install --global --attributes=.gitattributes. Dealing with that, may be out of the scope of the project. but wanted to raise the issue in case other users have similarly configured their filters.

Here's the filter that was clobbered by uninstalling/re-installing:

[filter "nbstripout"]
        clean = \"/mnt/c/users/jravi/miniconda3/bin/python3.7\" \"/mnt/c/users/jravi/miniconda3/lib/python3.7/site-packages/nbstripout\"
        smudge = cat
        required = true
        extrakeys = \n  metadata.celltoolbar metadata.kernel_spec.display_name\n  metadata.kernel_spec.name metadata.language_info.codemirror_mode.version\n  metadata.language_info.pygments_lexer metadata.language_info.version\n  metadata.toc metadata.notify_time metadata.varInspector\n  cell.metadata.heading_collapsed cell.metadata.hidden\n  cell.metadata.code_folding cell.metadata.tags cell.metadata.init_cell

The extrakeys field refers to metadata added by jupyter extensions.

Thanks for implementing the feature request, it will be very helpful!

@kynan
Copy link
Owner

kynan commented Jul 22, 2019

Tracked this in #102, thanks for flagging.

@kynan kynan closed this as completed Jul 22, 2019
ooiM added a commit to ooiM/nbstripout that referenced this issue Jun 2, 2020
Setting this flag writes the filter config to ~/.gitconfig
ooiM added a commit to ooiM/nbstripout that referenced this issue Jun 2, 2020
Also add an overview table of the different configuration options and
document them in the 'Manual filter installation' section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants