get rid of circular imports

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-10-25 10:42:11 +02:00
parent bf117d7f1e
commit 7573b65232
29 changed files with 88 additions and 83 deletions
@@ -20,7 +20,7 @@ import {
GerritIntegrationConfig,
readGerritIntegrationConfigs,
} from './config';
import { parseGerritGitilesUrl, builldGerritGitilesUrl } from './core';
import { parseGerritGitilesUrl, buildGerritGitilesUrl } from './core';
/**
* A Gerrit based integration.
@@ -61,7 +61,7 @@ export class GerritIntegration implements ScmIntegration {
let updated;
if (url.startsWith('/')) {
const { branch, project } = parseGerritGitilesUrl(this.config, base);
return builldGerritGitilesUrl(this.config, project, branch, url);
return buildGerritGitilesUrl(this.config, project, branch, url);
}
if (url) {
updated = new URL(url, base);
+3 -3
View File
@@ -20,7 +20,7 @@ import fetch from 'cross-fetch';
import { setupRequestMockHandlers } from '@backstage/test-utils';
import { GerritIntegrationConfig } from './config';
import {
builldGerritGitilesUrl,
buildGerritGitilesUrl,
getGerritBranchApiUrl,
getGerritCloneRepoUrl,
getGerritRequestOptions,
@@ -33,14 +33,14 @@ describe('gerrit core', () => {
const worker = setupServer();
setupRequestMockHandlers(worker);
describe('builldGerritGitilesUrl', () => {
describe('buildGerritGitilesUrl', () => {
it('can create an url from arguments', () => {
const config: GerritIntegrationConfig = {
host: 'gerrit.com',
gitilesBaseUrl: 'https://gerrit.com/gitiles',
};
expect(
builldGerritGitilesUrl(config, 'repo', 'dev', 'catalog-info.yaml'),
buildGerritGitilesUrl(config, 'repo', 'dev', 'catalog-info.yaml'),
).toEqual(
'https://gerrit.com/gitiles/repo/+/refs/heads/dev/catalog-info.yaml',
);
+3 -2
View File
@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { trimStart } from 'lodash';
import { GerritIntegrationConfig } from '.';
import { GerritIntegrationConfig } from './config';
const GERRIT_BODY_PREFIX = ")]}'";
@@ -79,7 +80,7 @@ export function parseGerritGitilesUrl(
* @param filePath - The absolute file path.
* @public
*/
export function builldGerritGitilesUrl(
export function buildGerritGitilesUrl(
config: GerritIntegrationConfig,
project: string,
branch: string,