ben-gibson / GitLink

A Jetbrains plugin that opens a local file under Git version control in its remote host using the default browser.
https://plugins.jetbrains.com/plugin/8183-gitlink
MIT License
728 stars 59 forks source link

Wrong support for port number in git URL #218

Closed schi2m closed 2 years ago

schi2m commented 2 years ago

Unfortunately plugin doesn't work properly if base repository URL is in following format "git-host-name:8082". In this case port is being removed and plugin creates wrong URL.

ben-gibson commented 2 years ago

Can you share the result of git-remove -v on your repository along with an example of the working HTTP URL you expect it produce?

schi2m commented 2 years ago

What git-remove -v does? I'm working on windows using git bash and I don't have aforementioned command.

But answering on your question about GIT LAB HTTP URL we're using in our company. This is the one I keep in mind when I posted this issue. The following URL I have defined in Custom hosts panel.

Domain: http://ocjenkinsc2-ref01:8082/ File at branch template: {remote:url}/tree/{branch}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end} File at commit template: {remote:url}/blob/{commit}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end} Commit template: {remote:url}/commit/{commit}

I have also unchecked option Force HTTPS

I have following remote configured in my project as an origin, which is SSH link.

git@ocjenkinsc2-ref01:kip/kip.git

And this is URL that is returned when i click Copy... Link for particular commit.

http://ocjenkinsc2-ref01/kip/kip/commit/92422a36

As you can see port number has been removed from resulting link. The same situation occurs when you select option Open in...

I hope this comment will be helpful.

ben-gibson commented 2 years ago

git-remove -v will show how the remote is configured, including the protocol it's using.

In may be, that we want to provide a new option in the plugin settings, either, to allow a specific port to be specified, or just a check box to determine if the port should be stripped away or not.

I think you can work around the issue either way for now, by replacing {remote:url} with http://ocjenkinsc2-ref01:8082 so your template becomes something like http://ocjenkinsc2-ref01:8082/{remote:url:path}/{branch}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end}

schi2m commented 2 years ago

Workaround that you've suggested works. Thanks.

One thing I need to tell more is, that now (I just noticed this) I can't even provide URL the way I did that earlier (several minor versions before). Now I can only provide domain name. Protocol name or port are not allowed and validation doesn't let me update configuration if any of these values are provided in domain field.

Obviously, as I moved this configuration into template fields, I simply could remove all that forbidden data from domain field, just to make "Update" button enabled.

ben-gibson commented 2 years ago

Yeah, that field is only used for automatically detecting the host when opening a new project so it doesn't need anything more than just the domain. In your case, if you set the domain to ocjenkinsc2-ref01.com, when you open a new project with the same remote, it should automatically select the custom host you just created so you don't need to do it manually.