Skip to content

Commit

Permalink
Change *Match/Matching properties to match full string instead of sub…
Browse files Browse the repository at this point in the history
  • Loading branch information
famod committed May 28, 2021
1 parent 655f27e commit 6cbf30a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ private static Pattern compilePattern(String patternString, Property property) {
private static Optional<Predicate<String>> compileOptionalPatternPredicate(Property property, Properties pluginProperties, Properties projectProperties) {
return property.getValueOpt(pluginProperties, projectProperties)
.map(patternString -> compilePattern(patternString, property))
.map(Pattern::asPredicate);
.map(Configuration::asMatchPredicate);
}

// for Java 8-10 compatibility, Java 11 has Pattern.asMatchPredicate() OOTB
private static Predicate<String> asMatchPredicate(Pattern pattern) {
return s -> pattern.matcher(s).matches();
}

public static enum BuildUpstreamMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void projectDependencyGraphMissing() throws Exception {
}

@Test
public void enabledForReferenceBranch() throws Throwable {
public void enabledForReferenceBranch() throws Exception {
projectProperties.setProperty(Property.disableIfReferenceBranchMatches.prefixedName(), "origin/\\d+\\.\\d+");

projectProperties.setProperty(Property.referenceBranch.prefixedName(), "feature/group-effort");
Expand All @@ -175,7 +175,7 @@ public void enabledForReferenceBranch() throws Throwable {
}

@Test
public void disabledForReferenceBranch() throws Throwable {
public void disabledForReferenceBranch() throws Exception {
projectProperties.setProperty(Property.disableIfReferenceBranchMatches.prefixedName(), "origin/\\d+\\.\\d+");

projectProperties.setProperty(Property.referenceBranch.prefixedName(), "origin/1.13");
Expand All @@ -187,7 +187,7 @@ public void disabledForReferenceBranch() throws Throwable {
}

@Test
public void enabledForCurrentBranch() throws Throwable {
public void enabledForCurrentBranch() throws Exception {
projectProperties.setProperty(Property.disableIfBranchMatches.prefixedName(), "master|develop|(release/.+)|(hotfix/.+)");

mockCurrentBranch("feature/cool-stuff");
Expand All @@ -198,7 +198,18 @@ public void enabledForCurrentBranch() throws Throwable {
}

@Test
public void disabledForCurrentBranch() throws Throwable {
public void enabledForCurrentBranch_quarkusStyle() throws Exception {
projectProperties.setProperty(Property.disableIfBranchMatches.prefixedName(), "main|\\d+\\.\\d+|.*backport.*");

mockCurrentBranch("bump-xyz-to-1.1");

underTest.afterProjectsRead(mavenSessionMock);

verify(unchangedProjectsRemoverMock).act(any(Configuration.class));
}

@Test
public void disabledForCurrentBranch() throws Exception {
projectProperties.setProperty(Property.disableIfBranchMatches.prefixedName(), "master|develop|(release/.+)|(hotfix/.+)");

mockCurrentBranch("develop");
Expand Down

0 comments on commit 6cbf30a

Please sign in to comment.