-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
pre-commit hook behaving differently in integrated terminal and source control panel #90178
Comments
You're missing some critical information:
If you run |
@joaomoreno Sorry about that. VSCode Version: 1.42.0
while in the VS Code console
So as expected, the Is this something that could be fixed by the Python extension? I.e. make it add the selected environment to |
VS Code tries to automatically source the |
Wouldn't that prevent me from changing the environment while I'm in that directory? I need the ability to sometimes deactivate the env or change to a different one. |
I have the same problem as well. I have the executable that a pre-commit hook needs installed in a conda environment. When I run git commit from the integrated terminal (which has the conda environment active), everything passes but trying to commit from the source control panel fails because it doesn't find the executable. As janosh said, this should ideally be a workspace-specific setting rather than through a global configuration file. I did test activating my conda environment through my .bashrc but that didn't fix the issue in the source control panel. I also tried adding ["-l"] to terminal.integrated.shellArgs.linux but I guess the panel isn't affected from that setting. I'm using VS code 1.41.1 on Windows 10, using the Remote-SSH extension to an Ubuntu 16.04 machine. |
@janosh It's just another way of reading the cwd. Now you seem to be preemtively running something to read cwd every time it changes. But you can also just have the tool which depends on cwd read it a the time it executes. The hook should read the cwd and behave accordingly, not preemptively. Could this work in your case? |
@joaomoreno Not quite sure how that would work. I'm using the I also tried getting rid of said custom environment activation completely and instead use |
I guess not, it seems specific to Git in VS Code instead. As a workaround, since VS Code spawns git with a given cwd, then you could always write a |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
Question: Does VS Code use hidden terminals for running git commands, or is it simply spawning a process? @joaomoreno |
Steps to reproduce
Create a repo and install
pre-commit
git init && pip install pre-commit
Create 3 files.
containing
Install
isort
commit hook viapre-commit install
.Attempt to commit
b.py
via VS Code's source control panel.isort
will abort the commit and make changes to the file, removing the line between the local and 3rd party import. Committing from the integrated terminal viagit add b.py && git commit -m foo
works just fine.Expected behaviour
Committing in source control panel should work just like from the command line.
Cause
I think this might be due to VS Code invoking
isort
without access to the environment of installed packages.isort
therefore thinksimport tensorflow as tf
references another local module likea.py
and imports of the same type shouldn't be separated by blank lines.Related
Issue originally opened against the Python extension.
The text was updated successfully, but these errors were encountered: