uwolfer / gerrit-intellij-plugin

Gerrit Code Review Tool Integration for the IntelliJ Platform
Apache License 2.0
495 stars 103 forks source link

gerrit plugin does not work for WSL2 projects #408

Open eekboom opened 3 years ago

eekboom commented 3 years ago

IDEA is clever enough to open projects correctly even if they are in the WSL2 file system (using the \wsl$.., path prefix). For git operations it then directly uses the git client installed in the wsl subsystem.

However when I try to check out a gerrit change using the plugin, then the project path is wrong and the operations fails with "Invalid reference: FETCH_HEAD". From IDEAs git Console log:

20:55:27.587: [acme] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false fetch //wsl$/Ubuntu-20.04/home/stephen/dev/work/acme 92394348d0b671a7e2a49cb8546288e11eae6734 --progress --prune
fatal: '//wsl$/Ubuntu-20.04/home/stephen/dev/work/acme' does not appear to be a git repository

IDEA executes that command directly in wsl2/Ubuntu, so paths there should not contain the "//wsl$/Ubuntu-20.04" prefix. When I try this on the wsl2 command line, it works fine:

git -c credential.helper= -c core.quotepath=false -c log.showSignature=false fetch /home/stephen/dev/work/acme 92394348d0b671a7e2a49cb8546288e11eae6734 --progress --prune
uwolfer commented 3 years ago

I do not have such a setup available to test. If you do have any suspicions what could cause the issues here, feedback would be very welcome.

eekboom commented 3 years ago

I assume that the gerrit plugin is using the "normal" project path as seen by Windows: //wsl$/Ubuntu-20.04/home/stephen/dev/work/acme However, IDEA executes the git command directly in the linux subsystem, so the prefix must be removed: /home/stephen/dev/work/acme I would guess that there is some logic in IDEA itself that handles this translation of file paths. I am not sure, if it is always so easy as just remove the //wsl$/ prefix and the first component after that.

uwolfer commented 3 years ago

Thanks for your feedback. Do you know if any other Git operation executed directly by IntelliJ works as expected? Do only plugin triggered Git operations fail?

eekboom commented 3 years ago

Yes, it seems that way: The standard git operations like fetch and push work fine. However it seems that the command lines for that command do not include the file path at all (instead the commands are just executed with the current directory == project path). It's only the gerrit plugin triggered actions that fail.