Skip to content

Commit

Permalink
Fix for JENKINS-71789
Browse files Browse the repository at this point in the history
Gerrit changes with the kind NO_CHANGE are not excluded
from building with exclude trivial rebase or exclude no code change.
This fixes that, since NO_CHANGE is even more trivial than those.
  • Loading branch information
TWestling committed Aug 24, 2023
1 parent dd757d5 commit cd8035b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<dependency>
<groupId>com.sonymobile.tools.gerrit</groupId>
<artifactId>gerrit-events</artifactId>
<version>2.19.0</version>
<version>2.21.0</version>
<exclusions>
<!-- Provided by core -->
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,13 @@ public boolean shouldTriggerOn(GerritTriggeredEvent event) {
return true;
}
if (excludeTrivialRebase
&& GerritChangeKind.TRIVIAL_REBASE == ((PatchsetCreated)event).getPatchSet().getKind()) {
&& (GerritChangeKind.TRIVIAL_REBASE == ((PatchsetCreated)event).getPatchSet().getKind()
|| GerritChangeKind.NO_CHANGE == ((PatchsetCreated)event).getPatchSet().getKind())) {
return false;
}
if (excludeNoCodeChange
&& GerritChangeKind.NO_CODE_CHANGE == ((PatchsetCreated)event).getPatchSet().getKind()) {
&& (GerritChangeKind.NO_CODE_CHANGE == ((PatchsetCreated)event).getPatchSet().getKind()
|| GerritChangeKind.NO_CHANGE == ((PatchsetCreated)event).getPatchSet().getKind())) {
return false;
}
if (excludePrivateState && ((PatchsetCreated)event).getChange().isPrivate()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void shouldNotFireOnDraftPatchsetWhenExcluded() {

/**
* Tests that it should not fire on trivial rebase when they are excluded.
* Also tests that we don't fire for no change while ignoring trivial rebases.
* @author Doug Kelly &lt;dougk.ff7@gmail.com&gt;
*/
@Test
Expand All @@ -68,10 +69,13 @@ public void shouldNotFireOnTrivialRebaseWhenExcluded() {
assertTrue(pluginPatchsetCreatedEvent.shouldTriggerOn(patchsetCreated));
patchsetCreated.getPatchSet().setKind(GerritChangeKind.TRIVIAL_REBASE);
assertFalse(pluginPatchsetCreatedEvent.shouldTriggerOn(patchsetCreated));
patchsetCreated.getPatchSet().setKind(GerritChangeKind.NO_CHANGE);
assertFalse(pluginPatchsetCreatedEvent.shouldTriggerOn(patchsetCreated));
}

/**
* Tests that it should not fire on no code changes when they are excluded.
* Also tests that we don't fire for no change while ignoring no code change.
* @author Doug Kelly &lt;dougk.ff7@gmail.com&gt;
*/
@Test
Expand All @@ -86,6 +90,8 @@ public void shouldNotFireOnNoCodeChangeWhenExcluded() {
assertTrue(pluginPatchsetCreatedEvent.shouldTriggerOn(patchsetCreated));
patchsetCreated.getPatchSet().setKind(GerritChangeKind.NO_CODE_CHANGE);
assertFalse(pluginPatchsetCreatedEvent.shouldTriggerOn(patchsetCreated));
patchsetCreated.getPatchSet().setKind(GerritChangeKind.NO_CHANGE);
assertFalse(pluginPatchsetCreatedEvent.shouldTriggerOn(patchsetCreated));
}

/**
Expand Down

0 comments on commit cd8035b

Please sign in to comment.