Sertion / vscode-gitblame

Visual Studio Code Extension - See Git Blame info in status bar.
https://marketplace.visualstudio.com/items/waderyan.gitblame
MIT License
72 stars 31 forks source link

Unable to open '': File is a directory. #84

Closed MaffooBristol closed 3 years ago

MaffooBristol commented 4 years ago

Whenever I try and click on the commit that comes up, this message shows:

Unable to open '': File is a directory.

It happens consistently even with vscode restarted

Sertion commented 4 years ago

Hey Matt. Thank you for the issue.

What do you mean by "click on the commit that comes up"? Can you describe what active files you have tried this with? Are you running extension version 4.0.1? Does the same message appear when you use the "Git Blame: Copy hash to clipboard" command from the Command Palette?

I'm sorry for all the questions but any answers will help a lot when trying to figure out what is wrong.

MaffooBristol commented 4 years ago

Hi sorry about the delayed response.

It appears to be a problem in the repos that use Bitbucket cloud.

I tried it in another that uses self-hosted Gitlab and it's fine...

MaffooBristol commented 4 years ago

Ps. Copying the hash to the clipboard is perfectly fine

MaffooBristol commented 4 years ago

And yes, 4.0.1

Sertion commented 4 years ago

Thank you for the answers. This one is weird.

Could you do me another favor?

What do you get from the following commands in the command line when you run git commands:

git symbolic-ref -q --short HEAD
git config --local --get branch.RETURN_VALUE_FROM_PREVIOUS_COMMAND.remote
git config --local --get remote.RETURN_VALUE_FROM_PREVIOUS_COMMAND.url

Please replace RETURN_VALUE_FROM_PREVIOUS_COMMAND with the value that the command above it prints.

MaffooBristol commented 4 years ago
$ git symbolic-ref -q --short HEAD
develop
$ git config --local --get branch.develop.remote
origin
$ git config --local --get remote.origin.url
git@bitbucket.org:mycompany/myproject.git
MaffooBristol commented 4 years ago

The repo which works with this plugin also returns an ssh-type git url too, by the way

Sertion commented 4 years ago

I'm stumped.

The only line in the extension that makes a difference between Bitbucket and anything else is extension.ts:186. That line should not be able to cause this. There is also the issue that even if the code gets as far as the commit info popup it should not show the view-button when there is no URL to open.

How it can be both empty and pass the non-empty check is a mystery. 😕

I have created a temporary version of the extension that uses a new "strict" mode for parsing URIs. It also adds a bit more logging. It would be very helpful if you could try it out and report back what it logs.

The new logs will look like this (in Output/Extension: gitblame):

[ 22:17:52 | info ] {"from":"getToolUrl","inferCommitUrl":true,"commitUrl":"","remote":"https://chromium.googlesource.com/chromium/src","origin":"https://chromium.googlesource.com/chromium/src","remoteUrl":"chromium.googlesource.com/chromium/src","parsedUrl":"","isUrl":false}
[ 22:17:52 | info ] {"from":"generateMessageActions","commitToolUrl":{"$mid":1,"path":"/chromium/src/commit/801dd275df4e58a433f8ee23f028acd2b869c04e","scheme":"https","authority":"chromium.googlesource.com"}}
[ 22:18:01 | info ] {"from":"generateMessageActions-action","commitToolUrl":{"$mid":1,"path":"/chromium/src/commit/801dd275df4e58a433f8ee23f028acd2b869c04e","scheme":"https","authority":"chromium.googlesource.com"}}

PS. Thank you so very much for being patient with me and helping me figuring out what is wrong!

MaffooBristol commented 4 years ago

Just installed your dev version (first time installing extensions from source so might have made some mistakes)

Clicking the button in the footer toolbar doesn't create a popup anymore. The log output is as follows:

[ 21:28:49 | command ] /usr/bin/git symbolic-ref -q --short HEAD
[ 21:28:49 | command ] /usr/bin/git config --local --get branch.mybranch.remote
[ 21:28:49 | command ] /usr/bin/git config --local --get remote.origin.url
[ 21:28:49 | command ] /usr/bin/git ls-remote --get-url origin
[ 21:28:49 | info ] {"from":"getToolUrl","inferCommitUrl":true,"commitUrl":"","remote":"git@bitbucket.org:company/repo.git","origin":"git@bitbucket.org:company/repo.git","remoteUrl":"git@bitbucket.org:company/repo","parsedUrl":"","isUrl":false}

Doesn't really seem to say much in my eyes 🤔

And no need to thank me, thanks to you for taking the time to help debug an issue on open source code!

MaffooBristol commented 4 years ago

Only thing I can see is that the remoteUrl doesn't include the .git extension- could that be something or is it a red herring?

MaffooBristol commented 4 years ago

Either way it appears to not be parsing the URL and doesn't think that it's a URL at all. Let me try it on the one that does work

MaffooBristol commented 4 years ago

The one that works includes the log line with commitToolUrl in it. The one that doesn't work never outputs that log line

Sertion commented 4 years ago

Looks like you installed it perfectly! 😄

The problem looks to have something to do with the URL itself. It looks like there is a bug in the extension that is allowing it to go as far as it does, but the URL is also suspect. I see that you have replaced it with a placeholder in all previous messages but it would be of very great help to see the "origin" value as it was printed in the log output. Could you perhaps send it to my email albin.jacobsson@gmail.com?

This is a version with a potential fix. It will most likely hide the view-button from the commit info dialog.

MaffooBristol commented 4 years ago

There's nothing suspect with the url as far as I know, just a standard team/repo type thing. I'll email you more info tomorrow, as it's quite late now. Cheers!

On Wed, 17 Jun 2020 at 22:54, Albin Jacobsson notifications@github.com wrote:

Looks like you installed it perfectly! 😄

The problem looks to have something to do with the URL itself. It looks like there is a bug in the extension that is allowing it to go as far as it does, but the URL is also suspect. I see that you have replaced it with a placeholder in all previous messages but it would be of very great help to see the "origin" value as it was printed in the log output. Could you perhaps send it to my email albin.jacobsson@gmail.com?

This is a version with a potential fix https://github.com/Sertion/vscode-gitblame/files/4795262/gitblame-issue-84.1.zip. It will most likely hide the view-button from the commit info dialog.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Sertion/vscode-gitblame/issues/84#issuecomment-645645424, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZE4PCQNUSAEJA2VQ5KFR3RXE3PRANCNFSM4NQ3RJTQ .

Sertion commented 3 years ago

I have uploaded a new version that should fix this issue. Please re-open if the issue persists.