github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/webui/src/lib/api/apiUtils.tsx (about) 1 import { branches } from "./index"; 2 3 export const findBranchRegexMatch = async ( 4 repoId: string, 5 prefix: string, 6 regex: string | RegExp, 7 resultsPerPage = 100 8 ): Promise<string | null> => { 9 let hasMore = true; 10 let after: string | undefined; 11 while (hasMore) { 12 const { results: branchList, pagination } = await branches.list( 13 repoId, 14 prefix, 15 after, 16 resultsPerPage 17 ); 18 // Once we type the API we can remove the eslint-disable 19 // eslint-disable-next-line @typescript-eslint/no-explicit-any 20 const branch = branchList.find((branch: any) => branch.id.match(regex)); 21 if (branch) { 22 return branch.id; 23 } 24 hasMore = pagination.has_more; 25 after = pagination.next_offset; 26 } 27 return null; 28 };