(users: string[], api: Api<T>)
| 118 | } |
| 119 | |
| 120 | const getReposOwnedByUsers = async <T>(users: string[], api: Api<T>) => { |
| 121 | const results = await Promise.allSettled(users.map(async (user) => { |
| 122 | try { |
| 123 | logger.debug(`Fetching repos for user ${user}...`); |
| 124 | |
| 125 | const { durationMs, data } = await measure(() => |
| 126 | paginate((page) => api.users.userListRepos(user, { |
| 127 | page, |
| 128 | })) |
| 129 | ); |
| 130 | |
| 131 | logger.debug(`Found ${data.length} repos owned by user ${user} in ${durationMs}ms.`); |
| 132 | return { |
| 133 | type: 'valid' as const, |
| 134 | data |
| 135 | }; |
| 136 | } catch (e: any) { |
| 137 | Sentry.captureException(e); |
| 138 | |
| 139 | if (e?.status === 404) { |
| 140 | const warning = `User ${user} not found or no access`; |
| 141 | logger.warn(warning); |
| 142 | return { |
| 143 | type: 'warning' as const, |
| 144 | warning |
| 145 | }; |
| 146 | } |
| 147 | throw e; |
| 148 | } |
| 149 | })); |
| 150 | |
| 151 | throwIfAnyFailed(results); |
| 152 | const { validItems: repos, warnings } = processPromiseResults<GiteaRepository>(results); |
| 153 | |
| 154 | return { |
| 155 | repos, |
| 156 | warnings, |
| 157 | }; |
| 158 | } |
| 159 | |
| 160 | const getReposForOrgs = async <T>(orgs: string[], api: Api<T>) => { |
| 161 | const results = await Promise.allSettled(orgs.map(async (org) => { |
no test coverage detected