chore: activate gerrit editURL by default
Signed-off-by: Andy LADJADJ <andy.ladjadj@adevinta.com>
This commit is contained in:
@@ -138,9 +138,10 @@ describe('GerritIntegration', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('resolve edit URL', () => {
|
||||
it('resolve Url when editUrl is disabled', () => {
|
||||
const integration = new GerritIntegration({
|
||||
host: 'gerrit-review.example.com',
|
||||
disableEditUrl: true,
|
||||
} as any);
|
||||
|
||||
// Resolve edit URLs is not applicable for gerrit. Return the input
|
||||
@@ -158,8 +159,8 @@ describe('GerritIntegration', () => {
|
||||
const integration = new GerritIntegration({
|
||||
host: 'gerrit-review.example.com',
|
||||
baseUrl: 'https://gerrit-review.example.com',
|
||||
enableEditUrl: true,
|
||||
gitilesBaseUrl: 'https://gerrit-review.example.com/gitiles',
|
||||
disableEditUrl: false,
|
||||
} as any);
|
||||
|
||||
expect(
|
||||
|
||||
@@ -75,15 +75,16 @@ export class GerritIntegration implements ScmIntegration {
|
||||
}
|
||||
|
||||
resolveEditUrl(url: string): string {
|
||||
if (this.config.enableEditUrl) {
|
||||
const parsed = parseGitilesUrlRef(this.config, url);
|
||||
return buildGerritEditUrl(
|
||||
this.config,
|
||||
parsed.project,
|
||||
parsed.ref,
|
||||
parsed.path,
|
||||
);
|
||||
if (this.config.disableEditUrl) {
|
||||
return url;
|
||||
}
|
||||
return url;
|
||||
|
||||
const parsed = parseGitilesUrlRef(this.config, url);
|
||||
return buildGerritEditUrl(
|
||||
this.config,
|
||||
parsed.project,
|
||||
parsed.ref,
|
||||
parsed.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('readGerritIntegrationConfig', () => {
|
||||
host: 'a.com',
|
||||
baseUrl: 'https://a.com/api',
|
||||
cloneUrl: 'https:a.com/clone',
|
||||
enableEditUrl: false,
|
||||
disableEditUrl: true,
|
||||
gitilesBaseUrl: 'https://a.com/git',
|
||||
username: 'u',
|
||||
password: ' p ',
|
||||
@@ -67,7 +67,7 @@ describe('readGerritIntegrationConfig', () => {
|
||||
host: 'a.com',
|
||||
baseUrl: 'https://a.com/api',
|
||||
cloneUrl: 'https:a.com/clone',
|
||||
enableEditUrl: false,
|
||||
disableEditUrl: true,
|
||||
gitilesBaseUrl: 'https://a.com/git',
|
||||
username: 'u',
|
||||
password: 'p',
|
||||
@@ -78,7 +78,7 @@ describe('readGerritIntegrationConfig', () => {
|
||||
const output = readGerritIntegrationConfig(
|
||||
buildConfig({
|
||||
host: 'a.com',
|
||||
enableEditUrl: true,
|
||||
disableEditUrl: false,
|
||||
gitilesBaseUrl: 'https://a.com/gerrit/plugins/gitiles',
|
||||
}),
|
||||
);
|
||||
@@ -86,7 +86,7 @@ describe('readGerritIntegrationConfig', () => {
|
||||
host: 'a.com',
|
||||
baseUrl: 'https://a.com',
|
||||
cloneUrl: 'https://a.com',
|
||||
enableEditUrl: true,
|
||||
disableEditUrl: false,
|
||||
gitilesBaseUrl: 'https://a.com/gerrit/plugins/gitiles',
|
||||
username: undefined,
|
||||
password: undefined,
|
||||
@@ -177,7 +177,7 @@ describe('readGerritIntegrationConfigs', () => {
|
||||
host: 'b.com',
|
||||
baseUrl: 'https://b.com/api',
|
||||
cloneUrl: 'https://b.com/api',
|
||||
enableEditUrl: undefined,
|
||||
disableEditUrl: undefined,
|
||||
gitilesBaseUrl: 'https://b.com/gerrit/plugins/gitiles',
|
||||
username: undefined,
|
||||
password: undefined,
|
||||
|
||||
@@ -45,9 +45,9 @@ export type GerritIntegrationConfig = {
|
||||
cloneUrl?: string;
|
||||
|
||||
/**
|
||||
* Activate the edit url feature available since Gerrit 3.9
|
||||
* Disable the edit url feature for Gerrit <= 3.8.
|
||||
*/
|
||||
enableEditUrl?: boolean;
|
||||
disableEditUrl?: boolean;
|
||||
|
||||
/**
|
||||
* Base url for Gitiles. This is needed for creating a valid
|
||||
@@ -80,7 +80,7 @@ export function readGerritIntegrationConfig(
|
||||
const host = config.getString('host');
|
||||
let baseUrl = config.getOptionalString('baseUrl');
|
||||
let cloneUrl = config.getOptionalString('cloneUrl');
|
||||
const enableEditUrl = config.getOptionalBoolean('enableEditUrl');
|
||||
const disableEditUrl = config.getOptionalBoolean('disableEditUrl');
|
||||
let gitilesBaseUrl = config.getString('gitilesBaseUrl');
|
||||
const username = config.getOptionalString('username');
|
||||
const password = config.getOptionalString('password')?.trim();
|
||||
@@ -119,7 +119,7 @@ export function readGerritIntegrationConfig(
|
||||
host,
|
||||
baseUrl,
|
||||
cloneUrl,
|
||||
enableEditUrl,
|
||||
disableEditUrl,
|
||||
gitilesBaseUrl,
|
||||
username,
|
||||
password,
|
||||
|
||||
Reference in New Issue
Block a user