Check for unset config params.
Signed-off-by: Gustaf Lundh <gustaf.lundh@axis.com>
This commit is contained in:
@@ -47,6 +47,7 @@ describe('gerrit core', () => {
|
||||
};
|
||||
const configWithDedicatedGitiles: GerritIntegrationConfig = {
|
||||
host: 'gerrit.com',
|
||||
baseUrl: 'https://gerrit.com/gerrit',
|
||||
gitilesBaseUrl: 'https://dedicated-gitiles-server.com/gerrit/gitiles',
|
||||
};
|
||||
it('can create an archive url for a branch', () => {
|
||||
|
||||
@@ -157,10 +157,15 @@ export function getAuthenticationPrefix(
|
||||
export function getGitilesAuthenticationUrl(
|
||||
config: GerritIntegrationConfig,
|
||||
): string {
|
||||
if (config.gitilesBaseUrl!.startsWith(config.baseUrl!)) {
|
||||
return config.gitilesBaseUrl!.replace(
|
||||
config.baseUrl!.concat('/'),
|
||||
config.baseUrl!.concat(getAuthenticationPrefix(config)),
|
||||
if (!config.baseUrl || !config.gitilesBaseUrl) {
|
||||
throw new Error(
|
||||
'Unexpected Gerrit config values. baseUrl or gitilesBaseUrl not set.',
|
||||
);
|
||||
}
|
||||
if (config.gitilesBaseUrl.startsWith(config.baseUrl)) {
|
||||
return config.gitilesBaseUrl.replace(
|
||||
config.baseUrl.concat('/'),
|
||||
config.baseUrl.concat(getAuthenticationPrefix(config)),
|
||||
);
|
||||
}
|
||||
if (config.password) {
|
||||
|
||||
Reference in New Issue
Block a user