(orgs: string[], api: Api<T>)
| 158 | } |
| 159 | |
| 160 | const getReposForOrgs = async <T>(orgs: string[], api: Api<T>) => { |
| 161 | const results = await Promise.allSettled(orgs.map(async (org) => { |
| 162 | try { |
| 163 | logger.debug(`Fetching repos for org ${org}...`); |
| 164 | |
| 165 | const { durationMs, data } = await measure(() => |
| 166 | paginate((page) => api.orgs.orgListRepos(org, { |
| 167 | limit: 100, |
| 168 | page, |
| 169 | })) |
| 170 | ); |
| 171 | |
| 172 | logger.debug(`Found ${data.length} repos for org ${org} in ${durationMs}ms.`); |
| 173 | return { |
| 174 | type: 'valid' as const, |
| 175 | data |
| 176 | }; |
| 177 | } catch (e: any) { |
| 178 | Sentry.captureException(e); |
| 179 | |
| 180 | if (e?.status === 404) { |
| 181 | const warning = `Organization ${org} not found or no access`; |
| 182 | logger.warn(warning); |
| 183 | return { |
| 184 | type: 'warning' as const, |
| 185 | warning |
| 186 | }; |
| 187 | } |
| 188 | throw e; |
| 189 | } |
| 190 | })); |
| 191 | |
| 192 | throwIfAnyFailed(results); |
| 193 | const { validItems: repos, warnings } = processPromiseResults<GiteaRepository>(results); |
| 194 | |
| 195 | return { |
| 196 | repos, |
| 197 | warnings, |
| 198 | }; |
| 199 | } |
| 200 | |
| 201 | const getRepos = async <T>(repoList: string[], api: Api<T>) => { |
| 202 | const results = await Promise.allSettled(repoList.map(async (repo) => { |
no test coverage detected