kawamataryo / copy-git-link

Provides a shortcut to copy permalink in their online Git repositories.
https://plugins.jetbrains.com/plugin/17756-copy-git-link
25 stars 13 forks source link

Permalink starts with https://null/null if project imported from https git url. #6

Open vladvershinin opened 2 years ago

vladvershinin commented 2 years ago

Hi!

At some point in time, I've started to get https://null/null/blob/.... links. Looks like something happens with my repo value as it returns from GitRepositoryManager.getInstance(project).getRepositoryForFileQuick(virtualFile) so repo?.remotes?.first()?.firstUrl doesn't match to the regexp .*(?:@|\\/\\/)(.[^:\\/]*).([^\\.]+)\\.git.

IntelliJ IDEA 2021.2.4 (Ultimate Edition) Build #IU-212.5712.43, built on December 21, 2021 Licensed to ООО «ЯНДЕКС»

Runtime version: 11.0.13+8-b1504.49 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 10.15.7 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 12 Registry: scala.erase.compiler.process.jdk.once=false Non-Bundled Plugins: com.ultrahob.zerolength.plugin2 (0.93), mobi.hsz.idea.gitignore (4.3.0), com.github.kawamataryo.copygithublink (0.3.1), com.vexus2.intellij.openingithub (1.0.6), org.jetbrains.plugins.hocon (2021.1.0), String Manipulation (8.27.203.5981.1), org.jetbrains.kotlin (212-1.6.10-release-923-IJ5457.46), org.intellij.scala (2021.2.30), zio.intellij.zio-intellij (2021.2.14.0), izhangzhihao.rainbow.brackets (6.21), com.google.idea.bazel.ijwb (2022.01.25.0.0-api-version-212), ru.yandex.verts.bazel-zio-test (0.3) Kotlin: 212-1.6.10-release-923-IJ5457.46

vladvershinin commented 2 years ago

I see now that I've imported my repository using Idea -> File -> New project from Version Control... And I used https://github.com/YandexClassifieds/projectname url to import. That's how git origin doesn't end with .git.

vladvershinin commented 2 years ago

I see now that I've imported my repository using Idea -> File -> New project from Version Control... And I used https://github.com/YandexClassifieds/projectname url to import. That's how git origin doesn't end with .git.

So, switch to git@github.com:YandexClassifieds/projectname.git help as workaround. But at least an indication would be appreciated in such situation for future users.

PRGfx commented 2 years ago

While the .git is a problem, in my case the regex also fails for URLs with a . in the path, e.g. user/namespace.package. Some of the supported URL formats don't come from sources I expect this plugin to link to, but the current regex looks a bit too restrictive to me.

(btw .git is also optional for ssh remote URLs)

kawamataryo commented 2 years ago

Sorry for the delay in replying. I understand the problem. I will try to fix the regular expression.

flakey-bit commented 1 year ago

Hey @kawamataryo any update on this?

Having trouble with URLs like

End up with https://null/null/blob/8a14b7c598c2e654cc52b40b8d22ba15324b6761/...

kawamataryo commented 1 year ago

Sorry for the delayed response. I plan to rectify this issue soon.

kawamataryo commented 1 year ago

I fixed it to work with URLs that don't have .git, However, it still does not work with URLs containing namespace.

dustinblue commented 6 months ago

I also get null with latest PHP Storm and plugin. I clone my repo with ssh and then open the directory in PHP Storm to start the project.

https://nullnull/null/blob/c4d8a5b99e35a340f821b378d68229e588f0ed96...