Searching the codebase

Report an issue View source Nightly · 7.3 · 7.2 · 7.1 · 7.0 · 6.5

Product overview

Bazel's code search and source browsing interface is a web-based tool for browsing Bazel source code repositories. You can use these features to navigate among different repositories, branches, and files. You can also view history, diffs, and blame information.

Getting started

To access the code search and source browsing interface, open https://source.bazel.build in your web browser.

The main screen appears. This screen contains the following components:

  1. The Breadcrumb toolbar. This toolbar displays your current location in the repository and allows you to move quickly to another location such as another repository, or another location within a repository, such as a file, branch, or commit.

  2. A list of repositories that you can browse.

At the top of the screen is a search box. You can use this box to search for specific files and code.

Working with repositories

Opening a repository

To open a repository, click its name from the main screen.

Alternatively, you can use the Breadcrumb toolbar to browse for a specificrepository. This toolbar displays your current location in the repository and allows you to move quickly to another location such as another repository, or another location within a repository, such as a file, branch, or commit.

Switch repositories

To switch to a different repository, select the repository from the Breadcrumb toolbar.

View a repository at a specific commit

To view a repository at a specific commit:

  1. From the view of the repository, select the file.
  2. From the Breadcrumb toolbar, open the Branch menu.
  3. In the submenu that appears, click Commit.
  4. Select the commit you want to view.

The interface now shows the repository as it existed at that commit.

Open a branch, commit, or tag

By default, the code search and source browsing interface opens a repository to the default branch. To open a different branch, from the Breadcrumb toolbar, click the Branch/Commit/Tag menu. A submenu opens, allowing you to select a branch using a branch name, a tag name, or through a search box.

  • To select a branch using a branch name, select Branch and then click the name of the branch.
  • To select a branch using a tag name, select Tag and then click the tag name.
  • To select a branch using a commit id, select Commit and then click the commit id.
  • To search for a branch, commit, or tag, select the corresponding item and type a search term in the search box.

Working with files

When you select a repository from the main screen, the screen changes to display a view of that repository. If a README file exists, its contents appear in the file pane, located on the right side of the screen. Otherwise, a list of repository's files and folders appear. On the left side of the screen is a tree view of the repository's files and folders. You can use this tree to browse and open specific files.

Notice that, when you are viewing a repository, the Breadcrumb toolbar now has three components:

  • A Repository menu, from which you can select different repositories
  • A Branch/Commit/Tag menu, from which you can select specific branches, tags, or commits
  • A File path box, which displays the name of the current file or folder and its corresponding path

Open a file

You can open a file by browsing to its directory and selecting it. The view of the repository updates to show the contents of the file in the file pane, and its location in the repository in the tree pane.

View file changes

To view file changes:

  1. From the view of the repository, select the file.
  2. Click BLAME, located in the upper-right corner.

The file pane updates to display who made changes to the file and when.

View change history

To view the change history of a file:

  1. From the view of the repository, select the file.
  2. Click HISTORY, located in the upper-right corner. The Change history pane appears, showing the commits for this file.

View code reviews

For Gerrit code reviews, you can open the tool directly from the Change History pane.

To view the code review for a file:

  1. From the view of the repository, select the file.
  2. Click HISTORY, located in the upper-right corner. The Change History pane appears, showing the commits for this file.
  3. Hover over a commit. A More button (three vertical dots) appears.
  4. Click the More button.
  5. Select View code review.

The Gerrit Code Review tool opens in a new browser window.

Open a file at a specific commit

To open a file at a specific commit:

  1. From the view of the repository, select the file.
  2. Click HISTORY, located in the upper-right corner. The Change History pane appears, showing the commits for this file.
  3. Hover over a commit. A VIEW button appears.
  4. Click the VIEW button.

Compare a file to a different commit

To compare a file at a different commit:

  1. From the view of the repository, select the file. To compare from two different commits, first open the file at that commit.
  2. Hover over a commit. A DIFF button appears.
  3. Click the DIFF button.

The file pane updates to display a side-by-side comparison between the two files. The oldest of the two commits is always on the left.

In the Change History pane, both commits are highlighted, and a label indicates if the commit is displayed on the left or the right.

To change either file, hover over the commit in the Change History pane. Then, click either the Left or Right button to have the open the commit on the left or right side of the diff.

Browsing cross references

Another way to browse source repositories is through the use of cross references. These references appear automatically as hyperlinks within a given source file.

To make cross references easier to identify, click Cross References, located in the upper-right corner. This option displays an underline below all cross references in a file.

Note: If Cross References is grayed out, it indicates that cross references are not available for that file.

Click a cross reference to open the Cross Reference pane. This pane contains two sections:

  • A Definition section, which lists the file or files that define the reference
  • A References section, which lists the files in which the reference also appears

Both sections display the name of the file, as well as the line or lines that contains the reference. To open a file from the Cross Reference pane, click the line number entry. The file appears in a new section of the pane, allowing you to continue to browse the file while keeping the original file in view.

You can continue to browse cross references using the Cross Reference pane, just as you can in the File pane. When you do, the pane displays a breadcrumb trail, which you can use to navigate between different cross references.

You can search for specific files or code snippets using the search box located at the top of the screen. Searches are always against the default branch.

All searches use RE2 regular expressions by default. If you do not want to use regular expressions, enclose your search in double quotes ( " ).

Note: To quickly search for a specific file, either add a backslash in front of the period, or enclose the entire file name in quotes.

foo\.java
"foo.java"

You can refine your search using the following filters.

Filter Other options Description Example
lang: language: Perform an exact match by file language. lang:java test
file: filepath:
path:
f:
case:yes Make the search case sensitive. By default, searches are not case-sensitive. case:yes Hello World
class: Search for a class name. class:MainClass
function: func: Search for a function name. function:print
- Negates the term from the search. hello -world
\ Escapes special characters, such as ., \, or (. run\(\)
"[term]" Perform a literal search. "class:main"

Additional Support

To report an issue, click the Feedback button that appears in the top right-hand corner of the screen and enter your feedback in the provided form.