Skip to main content

parseGerritGitilesUrl()

Home > @backstage/integration > parseGerritGitilesUrl

Parse a Gitiles URL and return branch, file path and project.

Signature:

function parseGerritGitilesUrl(config: GerritIntegrationConfig, url: string): {
branch: string;
filePath: string;
project: string;
};

Parameters

Parameter

Type

Description

config

GerritIntegrationConfig

url

string

An URL pointing to a file stored in git.

**Returns:**

{ branch: string; filePath: string; project: string; }

Remarks

Gerrit only handles code reviews so it does not have a native way to browse or showing the content of gits. Image if Github only had the "pull requests" tab.

Any source code browsing is instead handled by optional services outside Gerrit. The url format chosen for the Gerrit url reader is the one used by the Gitiles project. Gerrit will work perfectly with Backstage without having Gitiles installed but there are some places in the Backstage GUI with links to the url used by the url reader. These will not work unless the urls point to an actual Gitiles installation.

Gitiles url: https://g.com/optional\_path/{project}/+/refs/heads/{branch}/{filePath} https://g.com/a/optional\_path/{project}/+/refs/heads/{branch}/{filePath}