Skip to content

Commit 49df85d

Browse files
committed
Fix accidental commitfest move
1 parent 5ba9a6a commit 49df85d

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from django.db import migrations
2+
3+
4+
def undo_pg19_final_close(apps, schema_editor):
5+
CommitFest = apps.get_model("commitfest", "CommitFest")
6+
PatchOnCommitFest = apps.get_model("commitfest", "PatchOnCommitFest")
7+
PatchHistory = apps.get_model("commitfest", "PatchHistory")
8+
9+
STATUS_INPROGRESS = 3
10+
STATUS_CLOSED = 4
11+
STATUS_MOVED = 5
12+
13+
try:
14+
pg19_final = CommitFest.objects.get(name="PG19-Final")
15+
except CommitFest.DoesNotExist:
16+
# Not running against a database that has PG19-Final
17+
return
18+
19+
if pg19_final.status != STATUS_CLOSED:
20+
return
21+
22+
# Find patches that were auto-moved by cfbot when the commitfest closed.
23+
# These have PatchHistory entries with by_cfbot=True.
24+
moved_histories = PatchHistory.objects.filter(
25+
by_cfbot=True,
26+
what__startswith=f"Moved from CF {pg19_final.name} to CF ",
27+
)
28+
29+
moved_patch_ids = set(moved_histories.values_list("patch_id", flat=True))
30+
31+
for patch_id in moved_patch_ids:
32+
# Get the PatchOnCommitFest in PG19-Final (should be STATUS_MOVED)
33+
try:
34+
old_poc = PatchOnCommitFest.objects.get(
35+
patch_id=patch_id, commitfest=pg19_final
36+
)
37+
except PatchOnCommitFest.DoesNotExist:
38+
continue
39+
40+
if old_poc.status != STATUS_MOVED:
41+
continue
42+
43+
# Find the new PatchOnCommitFest that was created by the move. The
44+
# move preserves the original status, so we can read it from there.
45+
new_poc = (
46+
PatchOnCommitFest.objects.filter(patch_id=patch_id)
47+
.exclude(commitfest=pg19_final)
48+
.order_by("-enterdate")
49+
.first()
50+
)
51+
52+
if new_poc is None:
53+
continue
54+
55+
# Restore the old poc to its original status
56+
old_poc.status = new_poc.status
57+
old_poc.leavedate = None
58+
old_poc.save()
59+
60+
# Remove the new poc that was created by the move
61+
new_poc.delete()
62+
63+
# Delete the PatchHistory entries for these moves
64+
moved_histories.delete()
65+
66+
# Reopen the commitfest and fix the end date
67+
pg19_final.status = STATUS_INPROGRESS
68+
pg19_final.enddate = "2026-04-09"
69+
pg19_final.save()
70+
71+
72+
class Migration(migrations.Migration):
73+
dependencies = [
74+
("commitfest", "0017_make_topic_optional"),
75+
]
76+
77+
operations = [
78+
migrations.RunPython(undo_pg19_final_close, migrations.RunPython.noop),
79+
]

0 commit comments

Comments
 (0)