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
671 stars 58 forks source link

Gitlink can no longer be used with repos using sso:// URL scheme #254

Closed medington closed 1 year ago

medington commented 1 year ago

Any attempt to open to use GitLink with a repo that is configured with a remote using the sso:// URL scheme will result in the following error being generated when attempting to open the link:

java.lang.IllegalArgumentException: Invalid host 'sso'
    at uk.co.ben_gibson.url.Host.<init>(Host.kt:7)
    at uk.co.ben_gibson.url.Host.<init>(Host.kt)
    at uk.co.ben_gibson.url.Host$Companion.invoke(Host.kt:11)
    at uk.co.ben_gibson.url.URL$Companion.fromString(URL.kt:26)
    at uk.co.ben_gibson.git.link.git.RemoteExtensionsKt.getHttpUrl(RemoteExtensions.kt:41)
    at uk.co.ben_gibson.git.link.git.RemoteExtensionsKt.getDomain(RemoteExtensions.kt:14)
    at uk.co.ben_gibson.git.link.platform.PlatformDetector.getPlatformForRepository(PlatformDetector.kt:39)
    at uk.co.ben_gibson.git.link.platform.PlatformDetector.access$getPlatformForRepository(PlatformDetector.kt:17)
    at uk.co.ben_gibson.git.link.platform.PlatformDetector$detect$1.invoke(PlatformDetector.kt:26)
    at uk.co.ben_gibson.git.link.platform.PlatformDetector$detect$1.invoke(PlatformDetector.kt:26)
    at uk.co.ben_gibson.git.link.platform.PlatformDetector.getRepositoryForFile(PlatformDetector.kt:48)
    at uk.co.ben_gibson.git.link.platform.PlatformDetector.detect(PlatformDetector.kt:26)
    at uk.co.ben_gibson.git.link.listener.ApplicationStartupListener.detectPlatform(ApplicationStartupListener.kt:38)
    at uk.co.ben_gibson.git.link.listener.ApplicationStartupListener.runActivity(ApplicationStartupListener.kt:16)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runStartupActivity(StartupManagerImpl.kt:312)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivityAndMeasureDuration(StartupManagerImpl.kt:293)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivityAndMeasureDuration$default(StartupManagerImpl.kt:288)
    at com.intellij.ide.startup.impl.StartupManagerImpl$runPostStartupActivities$1$1.run(StartupManagerImpl.kt:245)
    at com.intellij.openapi.project.DumbServiceImpl.runWithWaitForSmartModeDisabled(DumbServiceImpl.java:645)
    at com.intellij.ide.startup.impl.StartupManagerImpl$runPostStartupActivities$1.accept(StartupManagerImpl.kt:244)
    at com.intellij.ide.startup.impl.StartupManagerImpl$runPostStartupActivities$1.accept(StartupManagerImpl.kt:62)
    at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processWithPluginDescriptor(ExtensionPointImpl.java:299)
    at com.intellij.openapi.extensions.ExtensionPointName.processWithPluginDescriptor(ExtensionPointName.java:144)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runPostStartupActivities(StartupManagerImpl.kt:239)
    at com.intellij.ide.startup.impl.StartupManagerImpl.access$runPostStartupActivities(StartupManagerImpl.kt:62)
    at com.intellij.ide.startup.impl.StartupManagerImpl$projectOpened$3$1.run(StartupManagerImpl.kt:189)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
    at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:277)
    at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:255)
    at com.intellij.ide.startup.impl.StartupManagerImpl$projectOpened$3.run(StartupManagerImpl.kt:189)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

This is reproducible by changing the origin remote on any repo to something like "sso://testserver/testproject".

This used to work in older releases, I haven't been using GitLink much for the last few months so not sure when it got broken.

Note that sso:// is used for the internal Git server at my place of work.

czcollier commented 1 year ago

+1 - can't use GitLink right now because of this.

ben-gibson commented 1 year ago

The exception should now be fixed in the latest version 4.2.5, but I'm not sure if the URL it generates will be correct?

medington commented 1 year ago

Thanks Ben. I confirmed the exception is gone, still need to play around with it a bit tomorrow to see if I can make it work now. I get a bit confused when it's using the path for commit vs branch from the settings. I'll post an update sometime tomorrow.

medington commented 1 year ago

Hi @ben-gibson I did some more extensive testing. Good news is this appears to be fixed and the URL's are correct (mostly, see details below).

I tested against 2 different internal servers that use the sso:// URL scheme for access from the command line both of which use the gitiles UI.

The simpler of the two, for user files, has no integrated Gerrit code review and works with traditional Github like branches. This repo seems to work fine for all the scenarios I tested (summarized below).

The other repo is configured with Gerrit. This works differently in that you don't really use branches like you would with Github. Instead, you use a special git push command (example below) with a single commit that is annotated with a change Id that links that commit to the code review.

That mechanism, I believe, throws a wrench in the works when you are doing anything other than trying to open file on the master branch where the local repo is also at the same SHA. Not sure if this could be made to work and I don't know that it did before the sso:// schema breakage either.

In my mind, it's a distinct problem from the exception issue. If this sounds like something you want to try to support, I can work with you on that, but at least having the ability to open commits when I'm on the master branch is a big improvement for me.

Testing procedure

  1. Check that "Open in..." works for files on master branch with no local commits ahead of remote (sha url used)
  2. Make a change, commit local, test open again (master branch url used)
  3. Create a branch, test open again (master branch url used)
  4. Push branch to remote*, test open again (sha url used)
  5. Open the log and open a commit

Steps 2-4 all give a 404 due to the sha being used where it doesn't exist in the UI, but all 5 work for the repo without Gerrit.

*Step 4 uses this for Gerrit configured repo:

git push origin HEAD:refs/for/master

Hope this is helpful. Really appreciate the fix, at least now I can mostly use the plugin again even if it's not perfect. Let me know if you want me to log another issue.