refactor/bugfix: simplify hasOpenHandsSuffix with provider lookup for gitlab/azure (#11877)

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
This commit is contained in:
Marco Dalalba 2025-12-03 09:34:21 -03:00 committed by GitHub
parent eaea8b3ce1
commit 14695a8f0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -606,10 +606,15 @@ export const shouldIncludeRepository = (
* @returns The query string for searching OpenHands repositories
*/
export const getOpenHandsQuery = (provider: Provider | null): string => {
if (provider === "gitlab") {
return "openhands-config";
}
return ".openhands";
const providerRepositorySuffix: Record<string, string> = {
gitlab: "openhands-config",
azure_devops: "openhands-config",
default: ".openhands",
} as const;
return provider && provider in providerRepositorySuffix
? providerRepositorySuffix[provider]
: providerRepositorySuffix.default;
};
/**
@ -621,12 +626,7 @@ export const getOpenHandsQuery = (provider: Provider | null): string => {
export const hasOpenHandsSuffix = (
repo: GitRepository,
provider: Provider | null,
): boolean => {
if (provider === "gitlab") {
return repo.full_name.endsWith("/openhands-config");
}
return repo.full_name.endsWith("/.openhands");
};
): boolean => repo.full_name.endsWith(`/${getOpenHandsQuery(provider)}`);
/**
* Build headers for V1 API requests that require session authentication