lguychard / phabricator-extension

Get code intelligence on Phabricator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sourcegraph Phabricator integration

Sourcegraph's Phabricator integration adds Sourcegraph code intelligence and search to Phabricator diffs and code files, so you get go-to-definition, find-references, hover tooltips, and code search embedded natively into Phabricator.

Installation

  1. Clone this repository to phabricator/src/extensions/sourcegraph (inside your Phabricator installation directory). See Phabricator's adding new classes and extensions docs for more information.
git clone -b release-v1.1 https://github.com/sourcegraph/phabricator-extension.git phabricator/src/extensions/sourcegraph
  1. Navigate to the Phabricator root directory and run bin/celerity map to add the static CSS/JS assets.

  2. Restart Phabricator.

Quickstart

  1. Update the Sourcegraph site configuration to allow scripts on your Phabricator instance to communicate with your Sourcegraph instance:
{
   // ...
   "corsOrigin": "$PHABRICATOR_URL"
   // ...
}
  1. Set the Phabricator sourcegraph.url configuration value to your Sourcegraph URL.

Configuration

You can update the Phabricator integration's configuration via the command line or Application Settings in your Phabricator instance.

sourcegraph.url (string)

URL to Sourcegraph Server.

For example:

'https://sourcegraph.example.com'

sourcegraph.repos (array)

If your Phabricator installation mirrors repositories from a different origin than Sourcegraph, you must specify a list of repository pathss (as displayed on Sourcegraph) and their corresponding Phabricator callsigns.

An array of objects, each mapping a Phabricator repository's callsign to the corresponding repository on Sourcegraph. Each object contains the following properties:

  • path (string, required) The path of the repository on Sourcegraph.

  • callsign (string, required) The Phabricator callsign for the repository.

For example:

'[{"path": "gitolite.example.org/foobar", "callsign": "FOO"}]'

Restarting Phabricator

How to restart Phabricator depends on how you installed it. Usually it is one of the following commands:

  • sudo service apache2 restart
  • supervisorctl -c /app/supervisord.conf restart php-fpm
  • supervisorctl -c /app/supervisord.conf restart nginx
  • supervisorctl -c /app/supervisord.conf restart nginx-ssl

If Phabricator is running via Bitnami's docker image use:

  • bin/phd restart inside your Phabricator installation directory.

See Phabricator's restart docs for more information.

Supported Versions

Known issues

Staging areas

When you commit a code change and run arc diff to push your changes to Phabricator, only the change's diff gets pushed. This means unless you run git push on your own, your commits won't be pushed to your remote repo. Because of this, Sourcegraph and other tools using this diff's information won't be able to find the contents of the diff. To get around this, Phabricator has an experimental feature called staging areas.

Staging areas are Git repositories that store all of the information for a given diff so that its position in a Git repository's history isn't lost. Learn more about Phabricator staging areas and how to enable them.

If there is no staging area enabled and we can't resolve the commit, Sourcegraph tries to apply the diff's patch set to simulate a staging area. This will work most of the time. However, there are several cases where this will fail. Two examples of cases where this would fail is when you run arc diff on a base that isn't in master or if you created a diff from the Phabricator UI. The only way to ensure reliable code intelligence on all Phabricator diffs is to enable staging areas for your repositories.

Reporting issues

For issues with or feature requests for this integration, file an issue. For any other issues or feedback related to Sourcegraph, use sourcegraph/issues.

About

Get code intelligence on Phabricator

License:MIT License


Languages

Language:PHP 79.9%Language:JavaScript 20.1%