Browser extension doesn't work in Phabricator
Created by: lawrence-tan
- Sourcegraph version: 3.12.5
- Platform information: Docker version
Steps to reproduce:
- install and launch Docker version of Sourcegraph
- add Phabricator-hosted git repository via the "Generic Git host" option
- add Phabricator connection
- install Chrome browser extension
- browse to a Differential revision in Phabricator
Expected behavior:
Code intel to show up.
Actual behavior:
Nothing happens. An error is logged in the Chrome console "Uncaught Error: could not parse repo details"
This appears to be happening because of the check here. The repository I'm trying to use is hosted on Phabricator, so the uri for the repository has the same host as the Phabricator webpage, and convertToDetails is never able to find a valid uri for this repository.
I was able to fix this locally by editing the javascript for the Chrome extension and removing the check against window.location.host.
Separately, it appears the logic in convertToDetails iterates through all returned uris, and uses the first one that doesn't match window.location.host. My set up had 2 disabled uris that had an older, deprecated location which appear first in the list or returned uris. I had to edit those to be the same as the current uri because Sourcegraph doesn't check the disabled field on the uri. Perhaps convertToDetails should check and skip disabled uris?