fix: reactivate removed repositories after edits (#784)

This commit is contained in:
Thomas Durieux
2026-08-20 14:33:09 +02:00
committed by GitHub
parent 7b585fdefd
commit adb0dcaec2
2 changed files with 31 additions and 9 deletions
+11 -5
View File
@@ -461,14 +461,20 @@ export function hasRepositorySourceChanged(
} }
/** /**
* An expired repository has had its cached files removed, so saving a valid * An expired or removed repository has had its cached files removed, so saving
* future expiration must rebuild it even when its GitHub source is unchanged. * a valid future expiration must rebuild it even when its GitHub source is
* unchanged.
*/ */
export function shouldReactivateExpiredRepository( export function shouldReactivateInactiveRepository(
model: IAnonymizedRepositoryDocument, model: IAnonymizedRepositoryDocument,
now = new Date() now = new Date()
): boolean { ): boolean {
if (model.status !== RepositoryStatus.EXPIRED) return false; if (
model.status !== RepositoryStatus.EXPIRED &&
model.status !== RepositoryStatus.REMOVED
) {
return false;
}
if (model.options.expirationMode === "never") return true; if (model.options.expirationMode === "never") return true;
const expirationDate = model.options.expirationDate; const expirationDate = model.options.expirationDate;
@@ -504,7 +510,7 @@ router.post(
const sourceChanged = hasRepositorySourceChanged(repo.model, repoUpdate); const sourceChanged = hasRepositorySourceChanged(repo.model, repoUpdate);
updateRepoModel(repo.model, repoUpdate); updateRepoModel(repo.model, repoUpdate);
const reactivating = shouldReactivateExpiredRepository(repo.model); const reactivating = shouldReactivateInactiveRepository(repo.model);
if (reactivating) { if (reactivating) {
repo.model.anonymizeDate = new Date(); repo.model.anonymizeDate = new Date();
+20 -4
View File
@@ -8,7 +8,7 @@ const {
} = require("../src/server/routes/conference"); } = require("../src/server/routes/conference");
const { const {
hasRepositorySourceChanged, hasRepositorySourceChanged,
shouldReactivateExpiredRepository, shouldReactivateInactiveRepository,
} = require("../src/server/routes/repository-private"); } = require("../src/server/routes/repository-private");
const { const {
processRemoveRepository, processRemoveRepository,
@@ -92,7 +92,7 @@ describe("repository update source detection", function () {
it("rebuilds an expired repository when its expiration is in the future", function () { it("rebuilds an expired repository when its expiration is in the future", function () {
const now = new Date("2026-08-20T00:00:00.000Z"); const now = new Date("2026-08-20T00:00:00.000Z");
expect( expect(
shouldReactivateExpiredRepository( shouldReactivateInactiveRepository(
{ {
status: "expired", status: "expired",
options: { options: {
@@ -108,7 +108,7 @@ describe("repository update source detection", function () {
it("does not rebuild an expired repository with a stale expiration", function () { it("does not rebuild an expired repository with a stale expiration", function () {
const now = new Date("2026-08-20T00:00:00.000Z"); const now = new Date("2026-08-20T00:00:00.000Z");
expect( expect(
shouldReactivateExpiredRepository( shouldReactivateInactiveRepository(
{ {
status: "expired", status: "expired",
options: { options: {
@@ -123,12 +123,28 @@ describe("repository update source detection", function () {
it("rebuilds an expired repository configured never to expire", function () { it("rebuilds an expired repository configured never to expire", function () {
expect( expect(
shouldReactivateExpiredRepository({ shouldReactivateInactiveRepository({
status: "expired", status: "expired",
options: { expirationMode: "never" }, options: { expirationMode: "never" },
}) })
).to.equal(true); ).to.equal(true);
}); });
it("rebuilds a removed repository when its expiration is in the future", function () {
const now = new Date("2026-08-20T00:00:00.000Z");
expect(
shouldReactivateInactiveRepository(
{
status: "removed",
options: {
expirationMode: "remove",
expirationDate: new Date("2027-01-31T04:18:02.444Z"),
},
},
now
)
).to.equal(true);
});
}); });
describe("removal workers", function () { describe("removal workers", function () {