(repoList: string[], api: Api<T>)
| 199 | } |
| 200 | |
| 201 | const getRepos = async <T>(repoList: string[], api: Api<T>) => { |
| 202 | const results = await Promise.allSettled(repoList.map(async (repo) => { |
| 203 | try { |
| 204 | logger.debug(`Fetching repository info for ${repo}...`); |
| 205 | |
| 206 | const [owner, repoName] = repo.split('/'); |
| 207 | const { durationMs, data: response } = await measure(() => |
| 208 | api.repos.repoGet(owner, repoName), |
| 209 | ); |
| 210 | |
| 211 | logger.debug(`Found repo ${repo} in ${durationMs}ms.`); |
| 212 | return { |
| 213 | type: 'valid' as const, |
| 214 | data: [response.data] |
| 215 | }; |
| 216 | } catch (e: any) { |
| 217 | Sentry.captureException(e); |
| 218 | |
| 219 | if (e?.status === 404) { |
| 220 | const warning = `Repository ${repo} not found or no access`; |
| 221 | logger.warn(warning); |
| 222 | return { |
| 223 | type: 'warning' as const, |
| 224 | warning |
| 225 | }; |
| 226 | } |
| 227 | throw e; |
| 228 | } |
| 229 | })); |
| 230 | |
| 231 | throwIfAnyFailed(results); |
| 232 | const { validItems: repos, warnings } = processPromiseResults<GiteaRepository>(results); |
| 233 | |
| 234 | return { |
| 235 | repos, |
| 236 | warnings, |
| 237 | }; |
| 238 | } |
| 239 | |
| 240 | // @see : https://docs.gitea.com/development/api-usage#pagination |
| 241 | const paginate = async <T>(request: (page: number) => Promise<HttpResponse<T[], any>>) => { |
no test coverage detected