gitkraken / vscode-gitlens

Supercharge Git inside VS Code and unlock untapped knowledge within each repository — Visualize code authorship at a glance via Git blame annotations and CodeLens, seamlessly navigate and explore Git repositories, gain valuable insights via rich visualizations and powerful comparison commands, and so much more
http://gitkraken.com/gitlens
Other
8.95k stars 1.28k forks source link

GitLens not using Automation Shell? #2057

Open edemaine opened 2 years ago

edemaine commented 2 years ago

I'm in a scenario where the Git extension works fine, but GitLens does not work. See attached log.

Conjecture: GitLens uses the default terminal instead of the default automation terminal. My default terminal is a Cygwin shell (which I prefer to use in Terminal). My default automation shell is Windows Command Prompt, as needed for running Git from VSCode. My shell configuration is as follows:

    "terminal.integrated.defaultProfile.windows": "Cygwin ZSH",
    "terminal.integrated.automationProfile.windows": {
      "path": "${env:windir}\\System32\\cmd.exe",
      "args": [],
      "icon": "terminal-cmd"
    },
    "terminal.integrated.profiles.windows": {
      "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell"
      },
      "Command Prompt": {
        "path": [
          "${env:windir}\\Sysnative\\cmd.exe",
          "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
      },
      "Git Bash": {
        "source": "Git Bash"
      },
      "Cygwin ZSH": {
        "path": [
          "c:\\cygwin\\bin\\zsh.exe",
          "c:\\cygwin64\\bin\\zsh.exe"
        ],
        "args": [
          "-i"
        ],
        "env": {
          "ZSH_HIGHLIGHT_DISABLE": "1"
        }
      }
    },

It seems that GitLens uses the Git extension for some interactions with Git, but directly runs Git for other interactions. In the latter case, perhaps it's running the wrong shell?

To clarify the log, "C:\Program Files\Git\cmd\git.exe" runs fine in Command Prompt, but does not run in a Cygwin shell. You can also see the /cygdrive/c/... path in the log, which is another sign that it's running in the Cygwin shell.

Elias-Graf commented 1 year ago

For me, the extension does not work at all in some cases, because the shell I'm using, is not compatible with the cmd / PowerShell format. I'm using the Nushell, and if I try to delete a branch from the graph, for example, I get the following output:

"c:/Program Files/Git/cmd/git.exe" -C "PATH" -c "core.editor=code-insiders --wait --reuse-window" branch --delete BRANCH_NAME
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #1:1:1]
 1 │  "c:/Program Files/Git/cmd/git.exe" -C "PATH" -c "core.editor=code-insiders --wait --reuse-window" branch --delete BRANCH_NAME
   ·                                     ─┬
   ·                                      ╰── expected operator
   ╰────

GitLense shouldn't really start in this shell, since I configured cmd to be the automation shell on Windows:

"terminal.integrated.automationProfile.windows": {
  "path": "cmd"
},

I should have the newest version of GitLens installed v2023.6.1205 pre-release.

jkelroy commented 1 year ago

Hello @edemaine and @Elias-Graf, looking into this issue I am unable to reproduce so it would be helpful if you can provide more context. For example, here is what I tried:

After this, I was able to work with GitLens as expected i.e. delete a branch. Is there any additional setup required to reproduce this?

Elias-Graf commented 1 year ago

Hello @jkelroy, thanks for looking into this.

I can reproduce it with the following settings.json:

{
    "gitlens.graph.layout": "editor",
    "terminal.integrated.profiles.windows": {
        "nu": {
            "path": "nu"
        }
    },
    "terminal.integrated.defaultProfile.windows": "nu",
    "terminal.integrated.automationProfile.windows": {
        "path": "cmd"
    }
}

VS Code Version:

Version: 1.79.2 (user setup)
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-14T08:57:04.379Z
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621

GitLense Version: v2023.6.1912 Pre-Release

This was performed on a completely fresh installation of VS Code through the winget package manager. I don't think I have any other configuration active.

Have you added the following line to your settings "terminal.integrated.defaultProfile.windows": "nu"? Doing so will cause the + button (New Terminal) to launch a nu shell, which will apparently also be used for some automation tasks.

jkelroy commented 1 year ago

Thanks for the additional information - I was able to reproduce this issue using those settings.

Elias-Graf commented 1 year ago

Hello, what's the ETA on this? I'm having this issue all the time, and having this fixed would be a huge time saver for me. I really enjoy the product otherwise.