In a recent announcement, a Code Search and Navigation tool named Sourcegraph was declared Open Source. As it makes navigating through Source Code much more convenient, the tool itself going Open Source is definitely a big plus for developers!
We’ve looked into its features and also tried to find out how it can be so helpful for developers who are used to navigate through code hosts like GitHub, GitLab and others quite regularly.
As stated on their GitHub page, Sourcegraph has the following features:
- Fast global Code search
- Intelligent Code recognition
- Code host Enhancement on GitHub, GitLab and more
- Extension API for easier third-party integration
Sourcegraph 3.5 Released
With Sourcegraph, every company has access to the same kind of tools that Google and Facebook developers use every day.Blunden, R. and Forney, C. (2019). Sourcegraph 3.5: Powerful new search filters, improved configuration, and Bitbucket Server repository permissions. [online] Sourcegraph. Available at: https://about.sourcegraph.com/blog/sourcegraph-3.5/.
- Multi-line search with newline (
- Restrict search results to repositories with recent activity
- Restrict search to repositories with or without a specific filename
- Introducing Bitbucket Server repository permissions
- Improved code reviews with line decorations in pull requests
- Powering code alerts with saved searches.
orgsfield to optimize repository syncing for GitHub organizations
- Repository syncing status for site admins
For more information, you can view the complete changelog.
You can deploy Sourcegraph on your server and configure it to work with your or your organization’s Git repositories. Once that’s done, you get a search engine where you can search all the codes.
But if you are a lone developer, like me, you can still use Sourcegraph on GitHub or GitHub alternatives like GitLab.
I am going to quickly show you how to use Sourcegraph for a better code navigation on GitHub.
Using Sourcegraph on GitHub
Security Issue Open on GitHub
During the first-half of June, I reported a security issue to Sourcegraph that is now currently open on GitHub. Apparently, the issue was fixed around a week ago but yet to be merged to the master branch. The issue is about the official Firefox extension that asks for access to all websites during installation while there should be a filter for repository sites only such as GitHub, GitLab, BitBucket and others. Originally, due a Firefox bug (now fixed), it could not be incorporated during early development.
This is how it looks like with the official Sourcegraph extension installed and when you view a file on the Vim repository on GitHub:
Note how we can see the new Sourcegraph buttons within the GitHub interface, thanks to the installed extension. One thing to note is that one need not even login into GitHub to navigate through hosted Code and their repositories in order to make use of the helpful features of Sourcegraph.
When you click on “View File”, the entire look changes and the file is opened for you in a completely new interface within the browser itself:
Without Sourcegraph, if you want to look for files with a particular format, say C++ .cpp files in this example, it is very difficult to filter and view them if we try to use GitHub’s own search engine within this repository:
But once you are using this extension, see how easily you can view all such files in one go within the repository:
Sourcegraph can narrow down through Code Search very intelligently as explained in this video:
Code intelligence in Sourcegraph is powered by Lang Server, which enables identifying the type of Programming Language you are using:
Learn more about its usefulness in the following video:
Bonus Tip on using Sourcegraph
Even without installing an extension on your browser, you can directly use Sourcegraph as an IDE on top of any repository on GitHub by just adding “sourcegraph.com/” as a prefix to the repository URL.
For example, the URL for the official Vim repository is:
To view the same through Sourcegraph, modify the URL as below and you’re good to go:
I’ve also tested this method with GitLab and it works there too! You can try other repositories as well! There is an unofficial extension called Open on Sourcegraph that uses this method on Firefox and Chrome.
Sourcegraph Developers have a master plan behind declaring it Open Source:
Make basic code intelligence ubiquitous (for every language, and in every editor, code host, etc.)
Make code review continuous and intelligent
Increase the amount and quality of open-source code
Here are the ways they suggest you can contribute to its Development:
- Submit pull requests to the Sourcegraph Open Source Project
- Actively participate in its continued development
- Add and improve documentation
- Build Sourcegraph extensions to Enhance Code viewing/reviewing on both Sourcegraph and GitHub
So this was a brief look into how Sourcegraph can make the developer’s life a lot more easier and hassle-free.
Are you a Developer? Would you like to adopt this new Open Source tool in your day-to-day programming tasks? Let us know in the comments section below.