Gitlab Workflow extension interferes with git in VS Code and GitLens if repository is located on mapped drive in Windows
Alright, this is going to be fun ^^
A rare edge case I suppose, but maybe we can find out what's happening here.
Summary
Opening a repository in VS Code on Windows on a mapped drive renders GitLens extension and VS Code integrated git almost unusable
Steps to reproduce
I was investigating strange behavior with both the GitLens extension as well as the VS Code shipped git integration with the maintainer Eric Amodio https://github.com/eamodio/vscode-gitlens/issues/1045
The root path of the repository was misidentified whenever I opened a project on a fileshare that was mapped to a drive letter.
After a deep dig into the code we found a fix that will be included with the next releases of both products. So if you want to reproduce this, you have to use GitLens <=11.1.3 or pure VS Code <=1.52.1
However, one interesting fact remained unsolved. While there was a bug in these code bases (using a relative path from the current working directory rather than an absolute path), it only occured when the GitLab Workflow extension was installed and enabled. Apparently the current working directory for VS Code and GitLens is changed by GitLab Workflow.
The "on a mapped drive" part of the problem is a result of the code in VS Code and GitLens, so let's ignore this for this issue. The important part is changing the current working directory from GitLab Workflow changes it for VS Code and GitLens as well
What is the current bug behavior?
Current working directory is changed for VS Code and GitLens extension
What is the expected correct behavior?
GitLab Workflow extension should change its current working directory isolated from other processes
Relevant logs and/or screenshots
For details regarding the specific side effects caused please look at https://github.com/eamodio/vscode-gitlens/issues/1045
Possible fixes
I cloned the current code of the GitLab Workflow extension and tried to find out where the problem originates.
I identified this line as root of the problem:
https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/main/src/git_service.ts#L50
As soon as I comment it out, the problem disappears... but it also breaks GitLab Workflow.
So, apparently we need to change the current working directory for GitLab Workflow to work, but can we do so without interfering with the "outside world"?
I don't quite understand yet why the others are affected. The cwd
argument is passed to execa()
https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/main/src/git_service.ts#L49-52
So I guess it has something to do with how execa
modifies the running process.