From 498e18b0741e5cfde22a6b77de57ddeed4bd47d3 Mon Sep 17 00:00:00 2001 From: smilejj91 Date: Thu, 28 Nov 2024 00:56:43 +0900 Subject: [PATCH 1/2] [bugfix] Fix Github Branch Commit Checks Bug - Fixed an issue where the job configuration was broken when saving after activating the Commit Message pattern option. - Fixed an issue where the job was not triggered even if it matched the Commit Message Pattern. --- .../impl/GitHubBranchCommitMessageCheck.java | 2 +- .../impl/GitHubBranchCommitEvent/config.groovy | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck.java b/github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck.java index f8b29c67..a159c51c 100644 --- a/github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck.java +++ b/github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck.java @@ -85,7 +85,7 @@ private GitHubBranchCause check(GHBranch remoteBranch, GitHubBranchRepositor List messages = supplier.get(); if (commitsAreAllowed(messages)) { LOG.debug("Commit messages {} for branch [{}] allowed, commit ignored.", messages, name); - return null; + return toCause(remoteBranch, localRepo, false, "Commit messages %s for branch [%s] allowed by check.", messages, name); } return toCause(remoteBranch, localRepo, true, "Commit messages %s for branch [%s] not allowed by check.", messages, name); diff --git a/github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchCommitEvent/config.groovy b/github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchCommitEvent/config.groovy index 48e892cf..af41e18d 100644 --- a/github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchCommitEvent/config.groovy +++ b/github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchCommitEvent/config.groovy @@ -10,13 +10,11 @@ if (instance == null) { } f.block { - table(style: 'width:100%; margin-left: 5px;') { - f.entry() { - f.hetero_list(name: "checks", - items: instance.checks, - descriptors: descriptor.getEventDescriptors(), - hasHeader: true - ) - } + f.entry() { + f.hetero_list(name: "checks", + items: instance.checks, + descriptors: descriptor.getEventDescriptors(), + hasHeader: true + ) } } From 00d74073851d434dfcf52d8b621ba0414c48d342 Mon Sep 17 00:00:00 2001 From: smilejj91 Date: Thu, 28 Nov 2024 21:05:05 +0900 Subject: [PATCH 2/2] [test] modify GitHubBranchCommitMessageCheckTest code --- .../impl/GitHubBranchCommitMessageCheckTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/github-pullrequest-plugin/src/test/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheckTest.java b/github-pullrequest-plugin/src/test/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheckTest.java index 6b0de6cd..a4879c17 100644 --- a/github-pullrequest-plugin/src/test/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheckTest.java +++ b/github-pullrequest-plugin/src/test/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheckTest.java @@ -69,7 +69,7 @@ public void testComparedCommitsReturnNoCause() { givenCommitMessages(); givenAMessagePattern(); whenComparedCommitsAreChecked(); - thenCheckHasNoEffect(); + thenBuildIsNotSkipped(); } @Test @@ -77,7 +77,7 @@ public void testLastCommitReturnNoCause() throws Exception { givenACommitMessage(); givenAMessagePattern(); whenLastCommitIsChecked(); - thenCheckHasNoEffect(); + thenBuildIsNotSkipped(); } @Test @@ -119,7 +119,11 @@ private void givenMessageShouldBeExcluded() { } private void thenBuildIsSkipped() { - assertThat("build triggered", result.isSkip(), equalTo(true)); + assertThat("build not triggered", result.isSkip(), equalTo(true)); + } + + private void thenBuildIsNotSkipped() { + assertThat("build triggered", result.isSkip(), equalTo(false)); } private void thenCheckHasNoEffect() {