From 67d0530796c4e5faed42f48ee25dbbd9988c5b73 Mon Sep 17 00:00:00 2001 From: sblausten Date: Wed, 5 Jun 2024 19:02:52 +0200 Subject: [PATCH] Fix bug in root repo import where catalog-info.yaml.hcl file breaks import Signed-off-by: sblausten --- .changeset/orange-beans-float.md | 5 +++++ .../src/analyzers/GithubLocationAnalyzer.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/orange-beans-float.md diff --git a/.changeset/orange-beans-float.md b/.changeset/orange-beans-float.md new file mode 100644 index 0000000000..7e31277890 --- /dev/null +++ b/.changeset/orange-beans-float.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Fix bug in root repo import where catalog-info.yaml.hcl file is found by search and breaks the import diff --git a/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts b/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts index 2648b1bcdc..e3b367eb14 100644 --- a/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts +++ b/plugins/catalog-backend-module-github/src/analyzers/GithubLocationAnalyzer.ts @@ -76,8 +76,13 @@ export class GithubLocationAnalyzer implements ScmLocationAnalyzer { const { owner, name: repo } = parseGitUrl(url); const catalogFile = catalogFilename || 'catalog-info.yaml'; + const fileParts = catalogFile.split('.'); + const extension = + fileParts.length > 0 + ? `extension:${fileParts[fileParts.length - 1]}` + : ''; - const query = `filename:${catalogFile} repo:${owner}/${repo}`; + const query = `filename:${catalogFile} ${extension} repo:${owner}/${repo}`; const integration = this.integrations.github.byUrl(url); if (!integration) {