update client.hasFile to prefer project.id, then namespacedPath, then empty string fallback

Signed-off-by: Claire Peng <clairep@spotify.com>
This commit is contained in:
Claire Peng
2025-09-22 12:49:07 +01:00
parent 53aedd6a17
commit d84bf17948
2 changed files with 4 additions and 4 deletions
@@ -344,17 +344,17 @@ export class GitLabClient {
* General existence check.
* @see {@link https://docs.gitlab.com/api/repository_files/#get-file-from-repository | GitLab Repository Files API}
*
* @param project - The path to the project, either the numeric ID or the namespaced path.
* @param projectIdentifier - The identifier of the project, either the numeric ID or the namespaced path.
* @param branch - The branch used to search
* @param filePath - The path to the file
*/
async hasFile(
project: string,
projectIdentifier: string,
branch: string,
filePath: string,
): Promise<boolean> {
const endpoint: string = `/projects/${encodeURIComponent(
project,
projectIdentifier,
)}/repository/files/${encodeURIComponent(filePath)}`;
const request = new URL(`${this.config.apiBaseUrl}${endpoint}`);
request.searchParams.append('ref', branch);
@@ -590,7 +590,7 @@ export class GitlabDiscoveryEntityProvider implements EntityProvider {
this.config.fallbackBranch;
const hasFile = await client.hasFile(
project.path_with_namespace ?? '',
project.id.toString() ?? project.path_with_namespace ?? '',
project_branch,
this.config.catalogFile,
);