Skip to content

Commit 9a2702f

Browse files
committed
Implement filters
1 parent 0fc5486 commit 9a2702f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/index.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { Octokit } from "@octokit/rest";
2+
import { minimatch } from "minimatch";
23
import PQueue from "p-queue";
3-
import * as request from "superagent";
4+
import request from "superagent";
45
import { configuration } from "./configuration.mjs";
56

67
async function getGithubRepositories(
78
username,
89
token,
910
mirrorPrivateRepositories,
1011
mirrorForks,
12+
include,
13+
exclude,
1114
) {
1215
const octokit = new Octokit({
1316
auth: token || null,
@@ -38,6 +41,12 @@ async function getGithubRepositories(
3841
repositories = repositories.filter((repository) => !repository.fork);
3942
}
4043

44+
repositories = repositories.filter(
45+
(repository) =>
46+
include.some((f) => minimatch(repository.name, f)) &&
47+
!exclude.some((f) => minimatch(repository.name, f)),
48+
);
49+
4150
return repositories;
4251
}
4352

@@ -136,12 +145,16 @@ async function main() {
136145
console.log(` - GITEA_TOKEN: ${config.gitea.token ? "****" : ""}`);
137146
console.log(` - SKIP_FORKS: ${config.github.skipForks}`);
138147
console.log(` - DRY_RUN: ${config.dryRun}`);
148+
console.log(` - INCLUDE: ${config.include}`);
149+
console.log(` - EXCLUDE: ${config.exclude}`);
139150

140151
const githubRepositories = await getGithubRepositories(
141152
config.github.username,
142153
config.github.token,
143154
config.github.privateRepositories,
144155
!config.github.skipForks,
156+
config.include,
157+
config.exclude,
145158
);
146159

147160
console.log(`Found ${githubRepositories.length} repositories on github`);

0 commit comments

Comments
 (0)