From 4d62dc15bb64b08682a55d7901780e67d942df30 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Thu, 26 Aug 2021 22:33:57 +0100 Subject: [PATCH] gh processor passes over repos without default branch Signed-off-by: Brian Fletcher --- .changeset/cuddly-impalas-wave.md | 5 +++++ .../ingestion/processors/GithubDiscoveryProcessor.ts | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .changeset/cuddly-impalas-wave.md diff --git a/.changeset/cuddly-impalas-wave.md b/.changeset/cuddly-impalas-wave.md new file mode 100644 index 0000000000..1199ef1482 --- /dev/null +++ b/.changeset/cuddly-impalas-wave.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +GitHub discovery processor passes over repositories that do not have a default branch diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts index 567f6536d0..8bed5b4858 100644 --- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts @@ -108,9 +108,15 @@ export class GithubDiscoveryProcessor implements CatalogProcessor { ); for (const repository of matching) { - const path = `/blob/${ - branch === '-' ? repository.defaultBranchRef.name : branch - }${catalogPath}`; + const branchName = branch === '-' ? repository.defaultBranchRef?.name : branch; + + if (!branchName) { + this.logger.info(`the repository ${repository.url} does not have a default branch, skipping`); + continue; + } + + const path = `/blob/${branchName}${catalogPath}`; + emit( results.location( {