MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / listGitLabBranches

Function listGitLabBranches

apps/web/src/lib/integrations/gitlab-service.ts:210–251  ·  view source on GitHub ↗
(
  owner: Owner,
  integrationId: string,
  projectPath: string // e.g., "group/project" or project ID
)

Source from the content-addressed store, hash-verified

208export async function getValidGitLabProjectAccessToken(
209 integration: PlatformIntegration,
210 projectId: string | number,
211 actor: GitLabCredentialActor
212): Promise<string> {
213 const metadata = requireMetadataRecord(integration.metadata);
214 const expectedInstanceUrl = normalizeInstanceUrl(
215 readOptionalMetadataString(metadata, 'gitlab_instance_url')
216 );
217 return requireAvailableGitLabCredential(
218 await fetchGitLabCredential(actor, {
219 credential: 'project-exact',
220 integrationId: integration.id,
221 projectId: requireGitLabProjectId(projectId),
222 }),
223 expectedInstanceUrl
224 );
225}
226
227/**
228 * List repositories accessible by a GitLab integration
229 * Returns cached repositories by default, fetches fresh from GitLab when forceRefresh is true
230 */
231export async function listGitLabRepositories(
232 owner: Owner,
233 integrationId: string,
234 actor: GitLabCredentialActor,
235 forceRefresh: boolean = false
236) {
237 const ownershipCondition =
238 owner.type === 'user'
239 ? eq(platform_integrations.owned_by_user_id, owner.id)
240 : eq(platform_integrations.owned_by_organization_id, owner.id);
241
242 const [integration] = await db
243 .select()
244 .from(platform_integrations)
245 .where(
246 and(
247 eq(platform_integrations.id, integrationId),
248 ownershipCondition,
249 eq(platform_integrations.platform, PLATFORM.GITLAB)
250 )
251 )
252 .limit(1);
253
254 if (!integration) {

Callers

nothing calls this directly

Calls 4

fetchGitLabBranchesFunction · 0.90
getValidGitLabTokenFunction · 0.85
normalizeInstanceUrlFunction · 0.85
limitMethod · 0.65

Tested by

no test coverage detected