Skip to content

Commit badc3d7

Browse files
committed
have the cron job add comments to patches
1 parent 034e6f6 commit badc3d7

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

cron.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,19 @@ function run_patch_stats() {
174174
try {
175175
$oldstatus = $patch->getStatus();
176176
$patch->updateStats();
177+
$newstatus = $patch->getStatus();
177178

178-
if ($patch->getStatus() != $oldstatus) {
179+
if ($newstatus != $oldstatus) {
180+
$patch->comments->add(
181+
new PatchComment($patch,
182+
"Status changed: $oldstatus$newstatus"));
179183
email_ta($group,
180184
"PIC1: Patch $patch->id status changed (group $group)",
181185
"Patch $patch->id of group $group changed status from " .
182-
"$oldstatus to " . $patch->getStatus() . "\n" .
186+
"$oldstatus to $newstatus\n" .
183187
link_patch($patch));
184188
echo "Patch $patch->id changed status from $oldstatus to ",
185-
$patch->getStatus(), "\n";
189+
$newstatus, "\n";
186190
} else {
187191
echo "Patch $patch->id status unchanged\n";
188192
}
@@ -251,6 +255,8 @@ function run_repository() {
251255
*/
252256
} else {
253257
$patch->status = PATCH_PR_OPEN_ILLEGAL;
258+
$patch->comments->add(
259+
new PatchComment($patch, "PR opened without approval"));
254260
error_group($group,
255261
"PIC1: PR opened without approval",
256262
"PR $pr of group $group was opened ".
@@ -262,7 +268,7 @@ function run_repository() {
262268

263269
if (!$processed) {
264270
$patch = Patch::factory($group, $pr->branchURL(), PATCH_BUGFIX, '',
265-
'Automatically generated', $group->prof(),
271+
'Automatically generated', null,
266272
/*ignore_errors=*/true);
267273
$patch->setPR($pr);
268274
$patch->status = PATCH_PR_OPEN_ILLEGAL;

entities/Patch.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ abstract class Patch
8383

8484
static function factory(ProjGroup $group, string $url, $type,
8585
string $issue_url, string $description,
86-
User $submitter,
86+
?User $submitter,
8787
bool $ignore_errors = false) : Patch {
8888
$repo = $group->getRepository();
8989
if (!$repo)

pages/editpatch.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
echo "<p>&nbsp;</p>\n";
2626
mk_box_left_begin();
2727

28-
$prev_status = $patch->status;
28+
$prev_status = $patch->getStatus();
2929

3030
$new_comment = trim($_POST['text'] ?? '');
3131
if ($new_comment && get_user()->role == ROLE_STUDENT) {
@@ -44,10 +44,9 @@
4444
}
4545

4646
if ($new_comment) {
47-
if ($patch->status != $prev_status) {
48-
$old = Patch::get_status_options()[$prev_status];
49-
$new = Patch::get_status_options()[$patch->status];
50-
$new_comment = "Status changed: $old$new\n\n$new_comment";
47+
$new_status = $patch->getStatus();
48+
if ($new_status != $prev_status) {
49+
$new_comment = "Status changed: $prev_status$new_status\n\n$new_comment";
5150
}
5251
$patch->comments->add(new PatchComment($patch, $new_comment, get_user()));
5352
}
@@ -103,7 +102,7 @@
103102
mk_box_end();
104103

105104
// notify students of the patch review
106-
if ($patch->status != $prev_status) {
105+
if ($patch->getStatus() != $prev_status) {
107106
$subject = null;
108107
$patchurl = $patch->getPatchURL();
109108
$pic1link = link_patch($patch);

0 commit comments

Comments
 (0)