Skip to main content

Sourcegraph

What is Sourcegraph?

Sourcegraph is a code search and intelligence tool for developers. It lets you search and explore all of your organisations code on the web, with integrations into your existing tools.

What does Sourcegraph do?

Sourcegraph’s main features are:

  • Code Search: fast, up-to-date, and scalable, with regexp support on any branch or commit without an indexing delay (and diff search)
  • Code intelligence: jump-to-definition, find references, and other smart, IDE-like code browsing features on any branch, commit, or PR/code review
  • Easy and secure self-hosted installation (your code never touches our servers)
  • Integrations with code hosts, code review tools, editors, web browsers, etc.

What do I use Sourcegraph for?

Sourcegraph helps you:

  • Find example code
  • Explore/read code (including during a code review)
  • Debug issues
  • Locate a specific piece of code
  • Determine the impact of changes

Sourcegraph makes it faster and easier to perform these tasks, for you and everyone else at your organisation.

Who should use Sourcegraph?

All developers, except:

  • Sourcegraph is more useful to developers working with larger codebases or teams (15+ developers).
  • Teams who are starting to perform historical reviews.

Code intelligence

Sourcegraph gives your development team cross-repository IDE-like features on your code:

  • Hover tooltips
  • Go-to-definition
  • Find references
  • Symbol search

Sourcegraph gives you code intelligence in Sourcegraph's web ui and in Gitlab.

Sourcegraph code search is fast, works across all your repositories at any commit, and has no indexing delay. Code search also includes advanced features, including:

  • Powerful, flexible query syntax
  • Commit diff search
  • Commit message search
  • Custom search scopes
  • Saved search monitoring

Integrations

Sourcegraph allows you to get code intelligence and code search on code files and code review diffs in your code host and review tool.

Batch changes

Create a batch change by specifying a search query to get a list of repositories and a script to run in each. You can also create a batch change on a monorepo by specifying which projects to run the script on. The batch change then lets you create changesets (a generic term for pull requests or merge requests) on all affected repositories or projects. Batch Changes allows you to track their progress until they're all merged. You can preview the changes and update them at any time. A batch change can also be used to track and manage manually created changesets.

Examples

Code Search

context:global content:"node:latest" lang:YAML
("[a-z0-9+/]{32,}=?"|'[a-z0-9+/]{32,}=?'|`[a-z0-9+/]{32,}=?`) o--BEGIN RSA PRIVATE K-- or token.+[a-z0-9+/]{32,}=['"]?\n type:commit
f:\.ts?$ /availabilities

Monitoring

context:global ("[a-z0-9+/]{32,}=?"|'[a-z0-9+/]{32,}=?'|`[a-z0-9+/]{32,}=?`) o--BEGIN RSA PRIVATE K-- or token.+[a-z0-9+/]{32,}=['"]?\n repo:^gitlab\.com/rapharacing/rapha-mobile/rides-service$ type:commit  patterntype:regexp

File diff

repo:^gitlab\.com/rapharacing/rapha-middleware/platform/inventory$ file:^constants/index\.ts$ type:diff

Resources