Skip to content

Add generic search result interface, and implement commit and diff search using it

Warren Gifford requested to merge generic-search into master

Created by: attfarhan

Part of https://github.com/sourcegraph/sourcegraph/issues/962

This PR adds a generic search result type, and implements repo, diff, and commit search matches using this type. Our normal text search (file matches) and symbol search, are not affected.

The GenericSearchResult type consists of the following fields:

  • Icon (string): different search result types show different icons, so we want to allow providers to select a relevant icon to display next to search results of type.
  • Title (string): The title is a prominently displayed header. We ask for a markdown string, so that providers can be as flexible as they want with what is displayed, and render the markdown in the Sourcegraph UI. For clients like src-cli, the title is displayed as is.
  • URL (string): The URL for the search result. This is for clients like src-cli, which will want to display a URL in raw format.
  • Detail (string, optional): A less prominently displayed header. This is displayed on the right-hand side of search result titles in the Sourcegraph UI. Not displayed in src-cli responses, and not required.
  • Matches ([SearchMatch]): The list of matches for a given search result. A single search result can have multiple matches. Each match can link to a different URL. SearchMatch consists of:
    • url (string): URL for the individual result match.
    • body (string): A markdown string containing the contents of the result match. The markdown string is rendered when displayed in the Sourcegraph UI.
    • highlights ([{line, character, length}]): A list of objects containing line, character, and length. This is used to highlight the actual matches in a line. These are only displayed when the body is a markdown code block.

closes https://github.com/sourcegraph/sourcegraph/issues/613

Merge request reports

Loading