|
1 | 1 | import { Octokit } from "@octokit/rest";
|
| 2 | +import { minimatch } from "minimatch"; |
2 | 3 | import PQueue from "p-queue";
|
3 |
| -import * as request from "superagent"; |
| 4 | +import request from "superagent"; |
4 | 5 | import { configuration } from "./configuration.mjs";
|
5 | 6 |
|
6 | 7 | async function getGithubRepositories(
|
7 | 8 | username,
|
8 | 9 | token,
|
9 | 10 | mirrorPrivateRepositories,
|
10 | 11 | mirrorForks,
|
| 12 | + include, |
| 13 | + exclude, |
11 | 14 | ) {
|
12 | 15 | const octokit = new Octokit({
|
13 | 16 | auth: token || null,
|
@@ -38,6 +41,12 @@ async function getGithubRepositories(
|
38 | 41 | repositories = repositories.filter((repository) => !repository.fork);
|
39 | 42 | }
|
40 | 43 |
|
| 44 | + repositories = repositories.filter( |
| 45 | + (repository) => |
| 46 | + include.some((f) => minimatch(repository.name, f)) && |
| 47 | + !exclude.some((f) => minimatch(repository.name, f)), |
| 48 | + ); |
| 49 | + |
41 | 50 | return repositories;
|
42 | 51 | }
|
43 | 52 |
|
@@ -136,12 +145,16 @@ async function main() {
|
136 | 145 | console.log(` - GITEA_TOKEN: ${config.gitea.token ? "****" : ""}`);
|
137 | 146 | console.log(` - SKIP_FORKS: ${config.github.skipForks}`);
|
138 | 147 | console.log(` - DRY_RUN: ${config.dryRun}`);
|
| 148 | + console.log(` - INCLUDE: ${config.include}`); |
| 149 | + console.log(` - EXCLUDE: ${config.exclude}`); |
139 | 150 |
|
140 | 151 | const githubRepositories = await getGithubRepositories(
|
141 | 152 | config.github.username,
|
142 | 153 | config.github.token,
|
143 | 154 | config.github.privateRepositories,
|
144 | 155 | !config.github.skipForks,
|
| 156 | + config.include, |
| 157 | + config.exclude, |
145 | 158 | );
|
146 | 159 |
|
147 | 160 | console.log(`Found ${githubRepositories.length} repositories on github`);
|
|
0 commit comments