mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-13 06:08:58 +02:00
fix: archive ownerless repositories without assigning ownership (#800)
This commit is contained in:
@@ -6,12 +6,15 @@ import { recoverRepositoryOwners } from "../core/recover-repository-owners";
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const apply = args.includes("--apply");
|
||||
let concurrency = 5;
|
||||
let repositoryId: mongoose.mongo.ObjectId | undefined;
|
||||
for (const arg of args) {
|
||||
if (arg.startsWith("--id=") && /^[a-f0-9]{24}$/i.test(arg.slice(5))) {
|
||||
if (/^--concurrency=([1-9]|[12][0-9]|3[0-2])$/.test(arg)) {
|
||||
concurrency = Number(arg.split("=")[1]);
|
||||
} else if (arg.startsWith("--id=") && /^[a-f0-9]{24}$/i.test(arg.slice(5))) {
|
||||
repositoryId = new mongoose.mongo.ObjectId(arg.slice(5));
|
||||
} else if (arg !== "--apply" && arg !== "--maintenance") {
|
||||
process.stderr.write("Usage: recover-repository-owners.js [--id=<MongoDB document ID>] [--apply --maintenance]\n");
|
||||
} else if (arg !== "--apply" && arg !== "--maintenance" && arg !== "--archive-unrecoverable" && arg !== "--archive-all-ownerless") {
|
||||
process.stderr.write("Usage: recover-repository-owners.js [--id=<MongoDB document ID>] [--apply --maintenance] [--archive-unrecoverable | --archive-all-ownerless] [--concurrency=1..32]\n");
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
@@ -24,7 +27,8 @@ async function main() {
|
||||
const uri = config.MONGODB_URI || `mongodb://${config.DB_USERNAME}:${config.DB_PASSWORD}@${config.DB_HOSTNAME}:27017/production`;
|
||||
await mongoose.connect(uri, { ...(config.MONGODB_URI ? {} : { authSource: "admin" }), autoIndex: false });
|
||||
const counts = await recoverRepositoryOwners(mongoose.connection.db, {
|
||||
apply, repositoryId,
|
||||
apply, repositoryId, concurrency, archiveUnrecoverable: args.includes("--archive-unrecoverable"),
|
||||
archiveAllOwnerless: args.includes("--archive-all-ownerless"),
|
||||
report: event => process.stdout.write(JSON.stringify(event) + "\n"),
|
||||
});
|
||||
process.stdout.write(JSON.stringify(counts) + "\n");
|
||||
|
||||
Reference in New Issue
Block a user