Skip to content

Commit e889572

Browse files
committed
Add change-integration-pass and change-integration-fail events
Task-numnber: QTQAINFRA-3621 Change-Id: Iccdaabb4aa1a658a9c7fd8141ea231489cf6fb44 Reviewed-by: Daniel Smith <[email protected]> (cherry picked from commit c0b9476)
1 parent 6e47972 commit e889572

File tree

4 files changed

+74
-10
lines changed

4 files changed

+74
-10
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (C) 2020 The Qt Company
3+
//
4+
5+
package com.googlesource.gerrit.plugins.qtcodereview;
6+
7+
import com.google.common.base.Supplier;
8+
import com.google.gerrit.reviewdb.client.Change;
9+
import com.google.gerrit.server.data.AccountAttribute;
10+
import com.google.gerrit.server.events.PatchSetEvent;
11+
12+
public class QtChangeIntegrationFailEvent extends PatchSetEvent {
13+
public static final String TYPE = "change-integration-fail";
14+
public Supplier<AccountAttribute> submitter;
15+
public String newRev;
16+
17+
public QtChangeIntegrationFailEvent(Change change) {
18+
super(TYPE, change);
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (C) 2020 The Qt Company
3+
//
4+
5+
package com.googlesource.gerrit.plugins.qtcodereview;
6+
7+
import com.google.common.base.Supplier;
8+
import com.google.gerrit.reviewdb.client.Change;
9+
import com.google.gerrit.server.data.AccountAttribute;
10+
import com.google.gerrit.server.events.PatchSetEvent;
11+
12+
public class QtChangeIntegrationPassEvent extends PatchSetEvent {
13+
public static final String TYPE = "change-integration-pass";
14+
public Supplier<AccountAttribute> submitter;
15+
public String newRev;
16+
17+
public QtChangeIntegrationPassEvent(Change change) {
18+
super(TYPE, change);
19+
}
20+
}

src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtCommandBuildApprove.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2019 The Qt Company
2+
// Copyright (C) 2020 The Qt Company
33
//
44

55
package com.googlesource.gerrit.plugins.qtcodereview;
@@ -317,11 +317,13 @@ private void updateChanges(
317317
ChangeData cd = item.getKey();
318318
Change change = cd.change();
319319
if (passed) {
320+
qtUtil.postChangeIntegrationPassEvent(change);
320321
sendMergeEvent(cd);
321322
sendMergedEmail(change.getId());
322323
logger.atInfo().log(
323324
"qtcodereview: staging-approve change %s merged into %s", change, destBranchKey);
324325
} else {
326+
qtUtil.postChangeIntegrationFailEvent(change);
325327
sendBuildFailedEmail(change.getId());
326328
logger.atInfo().log(
327329
"qtcodereview: staging-approve change %s rejected for %s", change, destBranchKey);

src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtUtil.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -684,15 +684,37 @@ public void postChangeStagedEvent(Change change) {
684684
}
685685
}
686686

687-
public void postChangeUnStagedEvent(Change change) {
688-
try {
689-
ChangeNotes notes = changeNotesFactory.createChecked(change.getId());
690-
QtChangeUnStagedEvent event = new QtChangeUnStagedEvent(change);
691-
event.change = changeAttributeSupplier(change, notes);
692-
eventDispatcher.get().postEvent(event);
693-
} catch (StorageException | PermissionBackendException e) {
694-
logger.atWarning().log("qtcodereview: postChangeUnStagedEvent failed: %s", e);
687+
public void postChangeUnStagedEvent(Change change) {
688+
try {
689+
ChangeNotes notes = changeNotesFactory.createChecked(change.getId());
690+
QtChangeUnStagedEvent event = new QtChangeUnStagedEvent(change);
691+
event.change = changeAttributeSupplier(change, notes);
692+
eventDispatcher.get().postEvent(event);
693+
} catch (StorageException | PermissionBackendException e) {
694+
logger.atWarning().log("qtcodereview: postChangeUnStagedEvent failed: %s", e);
695+
}
696+
}
697+
698+
public void postChangeIntegrationPassEvent(Change change) {
699+
try {
700+
ChangeNotes notes = changeNotesFactory.createChecked(change.getId());
701+
QtChangeIntegrationPassEvent event = new QtChangeIntegrationPassEvent(change);
702+
event.change = changeAttributeSupplier(change, notes);
703+
eventDispatcher.get().postEvent(event);
704+
} catch (StorageException | PermissionBackendException e) {
705+
logger.atWarning().log("qtcodereview: postChangeIntegrationPassEvent failed: %s", e);
706+
}
707+
}
708+
709+
public void postChangeIntegrationFailEvent(Change change) {
710+
try {
711+
ChangeNotes notes = changeNotesFactory.createChecked(change.getId());
712+
QtChangeIntegrationFailEvent event = new QtChangeIntegrationFailEvent(change);
713+
event.change = changeAttributeSupplier(change, notes);
714+
eventDispatcher.get().postEvent(event);
715+
} catch (StorageException | PermissionBackendException e) {
716+
logger.atWarning().log("qtcodereview: postChangeIntegrationFailEvent failed: %s", e);
717+
}
695718
}
696-
}
697719

698720
}

0 commit comments

Comments
 (0)