Use parseGitUri

This commit is contained in:
Mikael Östberg
2020-12-09 15:31:43 +01:00
parent 5066852ef2
commit 6e47fb6568
@@ -18,6 +18,7 @@ import * as YAML from 'yaml';
import { useApi, configApiRef } from '@backstage/core';
import { catalogImportApiRef } from '../api/CatalogImportApi';
import { ConfigSpec } from '../components/ImportComponentPage';
import parseGitUri from 'git-url-parse';
// TODO: (O5ten) Refactor into a core API instead of direct usage like this
// https://github.com/backstage/backstage/pull/3613#issuecomment-7408929430
@@ -28,9 +29,12 @@ export function useGithubRepos() {
const config = useApi(configApiRef);
const submitPrToRepo = async (selectedRepo: ConfigSpec) => {
const [hostname, ownerName, repoName] = selectedRepo.location
.split('/')
.slice(-3);
const {
name: repoName,
owner: ownerName,
resource: hostname,
} = parseGitUri(selectedRepo.location);
const configs = readGitHubIntegrationConfigs(
config.getOptionalConfigArray('integrations.github') ?? [],
);