From 4a5fd284ee536ecde94967f24596b99a0b965945 Mon Sep 17 00:00:00 2001 From: Nikolas Skoufis Date: Mon, 10 Oct 2022 18:31:00 +1100 Subject: [PATCH] Strip leading slash if present in catalog path ref Without this, the graphql query fails to return matching catalog paths Signed-off-by: Nikolas Skoufis --- plugins/catalog-backend-module-github/src/lib/github.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend-module-github/src/lib/github.ts b/plugins/catalog-backend-module-github/src/lib/github.ts index 7fc69d0f86..ef6a7f817a 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.ts @@ -273,7 +273,14 @@ export async function getOrganizationRepositories( org: string, catalogPath: string, ): Promise<{ repositories: Repository[] }> { - const catalogPathRef = `HEAD:${catalogPath}`; + let relativeCatalogPathRef: string; + // We must strip the leading slash or the query for objects does not work + if (catalogPath.startsWith('/')) { + relativeCatalogPathRef = catalogPath.substring(1); + } else { + relativeCatalogPathRef = catalogPath; + } + const catalogPathRef = `HEAD:${relativeCatalogPathRef}`; const query = ` query repositories($org: String!, $catalogPathRef: String!, $cursor: String) { repositoryOwner(login: $org) {