Skip to content

Commit

Permalink
Rename *Regex properties to *Matching/*Matches
Browse files Browse the repository at this point in the history
  • Loading branch information
famod committed Mar 14, 2021
1 parent 90a05ea commit b8916f6
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 42 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This extension is **not limited to Git Flow setups!** The [extensive configurati
- [Configuration](#configuration)
- [gib.help](#gibhelp)
- [gib.disable](#gibdisable)
- [gib.disableIfBranchRegex](#gibdisableifbranchregex)
- [gib.disableIfBranchMatches](#gibdisableifbranchmatches)
- [gib.disableBranchComparison](#gibdisablebranchcomparison)
- [gib.referenceBranch](#gibreferencebranch)
- [gib.fetchReferenceBranch](#gibfetchreferencebranch)
Expand All @@ -38,8 +38,8 @@ This extension is **not limited to Git Flow setups!** The [extensive configurati
- [gib.uncommitted](#gibuncommitted)
- [gib.untracked](#gibuntracked)
- [gib.skipIfPathMatches](#gibskipifpathmatches)
- [gib.excludePathRegex](#gibexcludepathregex)
- [gib.includePathRegex](#gibincludepathregex)
- [gib.excludePathsMatching](#gibexcludepathsmatching)
- [gib.includePathsMatching](#gibincludepathsmatching)
- [gib.buildAll](#gibbuildall)
- [gib.buildAllIfNoChanges](#gibbuildallifnochanges)
- [gib.buildDownstream](#gibbuilddownstream)
Expand Down Expand Up @@ -325,7 +325,7 @@ Maven pom properties configuration with default values is below:
<properties>
<gib.help>false</gib.help> <!-- or -Dgib.h=... -->
<gib.disable>false</gib.disable> <!-- or -Dgib.d=... -->
<gib.disableIfBranchRegex></gib.disableIfBranchRegex> <!-- or -Dgib.dibr=... -->
<gib.disableIfBranchMatches></gib.disableIfBranchMatches> <!-- or -Dgib.dibm=... -->
<gib.disableBranchComparison>false</gib.disableBranchComparison> <!-- or -Dgib.dbc=... -->
<gib.referenceBranch>refs/remotes/origin/develop</gib.referenceBranch> <!-- or -Dgib.rb=... -->
<gib.fetchReferenceBranch>false</gib.fetchReferenceBranch> <!-- or -Dgib.frb=... -->
Expand All @@ -336,8 +336,8 @@ Maven pom properties configuration with default values is below:
<gib.uncommitted>true</gib.uncommitted> <!-- or -Dgib.uc=... -->
<gib.untracked>true</gib.untracked> <!-- or -Dgib.ut=... -->
<gib.skipIfPathMatches></gib.skipIfPathMatches> <!-- or -Dgib.sipm=... -->
<gib.excludePathRegex></gib.excludePathRegex> <!-- or -Dgib.epr=... -->
<gib.includePathRegex></gib.includePathRegex> <!-- or -Dgib.ipr=... -->
<gib.excludePathsMatching></gib.excludePathsMatching> <!-- or -Dgib.epm=... -->
<gib.includePathsMatching></gib.includePathsMatching> <!-- or -Dgib.ipm=... -->
<gib.buildAll>false</gib.buildAll> <!-- or -Dgib.ba=... -->
<gib.buildAllIfNoChanges>false</gib.buildAllIfNoChanges> <!-- or -Dgib.bainc=... -->
<gib.buildDownstream>always</gib.buildDownstream> <!-- or -Dgib.bd=... -->
Expand Down Expand Up @@ -393,7 +393,7 @@ Can be used to disable this extension temporarily or permanently (e.g. to avoid

Since: 3.11.2 (replaces previously used `enabled` property)

### gib.disableIfBranchRegex
### gib.disableIfBranchMatches

Can be used to disable this extension on certain branches (e.g. `master|develop`). By default, GIB runs on all branches.

Expand Down Expand Up @@ -477,27 +477,27 @@ By setting this property to e.g. `\.github[/\\].*` you can tell GIB that this pa

Since: 3.12.2

### gib.excludePathRegex
### gib.excludePathsMatching

Can be used to exclude certain changed files from being detected as changed, reducing the number of modules to build. By default, nothing is excluded.

The regular expression does _not_ need to describe the entire (absolute) path, but only the relevant part _inside_ the git repository context. Example:
```
/tmp/repo/blacklisted/some-file.txt
```
will be excluded when using `-Dgib.excludePathRegex=blacklisted` or `-Dgib.excludePathRegex=some-file\..*` etc., but is _not_ excluded when adding to the regular expression anything _outside_ of the git repository context like `/tmp/repo` or `repo`.
will be excluded when using `-Dgib.excludePathsMatching=blacklisted` or `-Dgib.excludePathsMatching=some-file\..*` etc., but is _not_ excluded when adding to the regular expression anything _outside_ of the git repository context like `/tmp/repo` or `repo`.

This the opposite of [gib.includePathRegex](#gibincludepathregex) which can be combined with this property, but `gib.excludePathRegex` will take precedence.
This the opposite of [gib.includePathsMatching](#gibincludepathregex) which can be combined with this property, but `gib.excludePathsMatching` will take precedence.

:information_source: Use `[/\\]` instead of just `/` to also cover Windows path separators.

### gib.includePathRegex
### gib.includePathsMatching

Can be used to include only certain changed files from being detected as changed, reducing the number of modules to build. By default, everything is included.

This the opposite of [gib.excludePathRegex](#gibexcludepathregex) which can be combined with this property, but `gib.excludePathRegex` will take precedence.
This the opposite of [gib.excludePathsMatching](#gibexcludepathregex) which can be combined with this property, but `gib.excludePathsMatching` will take precedence.

See [gib.excludePathRegex](#gibexcludepathregex) for general path matching rules.
See [gib.excludePathsMatching](#gibexcludepathregex) for general path matching rules.

:information_source: Use `[/\\]` instead of just `/` to also cover Windows path separators.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Configuration {

public final boolean help;
public final boolean disable;
public final Optional<Predicate<String>> disableIfBranchRegex;
public final Optional<Predicate<String>> disableIfBranchMatches;

public final boolean disableBranchComparison;
public final String referenceBranch;
Expand All @@ -52,8 +52,8 @@ public class Configuration {
public final boolean uncommitted;
public final boolean untracked;
public final Optional<Predicate<String>> skipIfPathMatches;
public final Optional<Predicate<String>> excludePathRegex;
public final Optional<Predicate<String>> includePathRegex;
public final Optional<Predicate<String>> excludePathsMatching;
public final Optional<Predicate<String>> includePathsMatching;

public final boolean buildAll;
public final boolean buildAllIfNoChanges;
Expand Down Expand Up @@ -82,7 +82,7 @@ public Configuration(MavenSession session) {
help = Boolean.parseBoolean(Property.help.getValue(pluginProperties, projectProperties));
disable = Boolean.parseBoolean(Property.disable.getValue(pluginProperties, projectProperties));
if (disable) { // abort parsing any other config properties if not enabled at all
disableIfBranchRegex = null;
disableIfBranchMatches = null;

// change detection config

Expand All @@ -96,8 +96,8 @@ public Configuration(MavenSession session) {
uncommitted = false;
untracked = false;
skipIfPathMatches = null;
excludePathRegex = null;
includePathRegex = null;
excludePathsMatching = null;
includePathsMatching = null;

// build config

Expand Down Expand Up @@ -126,7 +126,7 @@ public Configuration(MavenSession session) {

Property.checkProperties(pluginProperties, projectProperties);

disableIfBranchRegex = compileOptionalPatternPredicate(Property.disableIfBranchRegex, pluginProperties, projectProperties);
disableIfBranchMatches = compileOptionalPatternPredicate(Property.disableIfBranchMatches, pluginProperties, projectProperties);

// change detection config

Expand All @@ -140,8 +140,8 @@ public Configuration(MavenSession session) {
uncommitted = Boolean.parseBoolean(Property.uncommitted.getValue(pluginProperties, projectProperties));
untracked = Boolean.parseBoolean(Property.untracked.getValue(pluginProperties, projectProperties));
skipIfPathMatches = compileOptionalPatternPredicate(Property.skipIfPathMatches, pluginProperties, projectProperties);
excludePathRegex = compileOptionalPatternPredicate(Property.excludePathRegex, pluginProperties, projectProperties);
includePathRegex = compileOptionalPatternPredicate(Property.includePathRegex, pluginProperties, projectProperties);
excludePathsMatching = compileOptionalPatternPredicate(Property.excludePathsMatching, pluginProperties, projectProperties);
includePathsMatching = compileOptionalPatternPredicate(Property.includePathsMatching, pluginProperties, projectProperties);

// build config

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void perform(Configuration config) throws MavenExecutionException {
}

private boolean isDisabledForBranch(Configuration config) {
return config.disableIfBranchRegex.map(predicate -> {
return config.disableIfBranchMatches.map(predicate -> {
try {
return predicate.test(gitProvider.get(config).getRepository().getBranch());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ private boolean pathIncluded(Path path) {
if (configuration.skipIfPathMatches.map(pred -> pred.test(pathString)).orElse(false)) {
throw new SkipExecutionException("Changed path matches regex defined by skipIfPathMatches: " + pathString);
}
boolean excluded = configuration.excludePathRegex.map(pred -> pred.test(pathString)).orElse(false);
boolean included = !excluded && configuration.includePathRegex.map(pred -> pred.test(pathString)).orElse(true);
boolean excluded = configuration.excludePathsMatching.map(pred -> pred.test(pathString)).orElse(false);
boolean included = !excluded && configuration.includePathsMatching.map(pred -> pred.test(pathString)).orElse(true);
logger.debug("included {}: {}", included, pathString);
return included;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ public enum Property {
/**
* Can be used to disable this extension on certain branches.
*/
disableIfBranchRegex("", "dibr"),
disableIfBranchMatches("", "dibm") {
@Override
public Optional<String> deprecatedName() {
return Optional.of("disableIfBranchRegex");
}
},

/**
* Disables the comparison between baseBranch and referenceBranch.
Expand Down Expand Up @@ -80,11 +85,21 @@ public enum Property {
/**
* Can be used to exclude certain changed files from being detected as changed, reducing the number of modules to build.
*/
excludePathRegex("", "epr"),
excludePathsMatching("", "epm") {
@Override
public Optional<String> deprecatedName() {
return Optional.of("excludePathRegex");
}
},
/**
* Can be used to include only certain changed files from being detected as changed, reducing the number of modules to build.
*/
includePathRegex("", "ipr"),
includePathsMatching("", "ipm") {
@Override
public Optional<String> deprecatedName() {
return Optional.of("includePathRegex");
}
},

/**
* Builds all modules, including upstream modules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void disable() {
Configuration configuration = new Configuration(mavenSessionMock);

assertThat(configuration.disable).isTrue();
assertThat(configuration.disableIfBranchRegex).isNull();
assertThat(configuration.disableIfBranchMatches).isNull();
}

@Test
Expand All @@ -126,7 +126,7 @@ public void disable_projectProperties() {
Configuration configuration = new Configuration(mavenSessionMock);

assertThat(configuration.disable).isTrue();
assertThat(configuration.disableIfBranchRegex).isNull();
assertThat(configuration.disableIfBranchMatches).isNull();
}

@Test
Expand All @@ -137,7 +137,7 @@ public void disable_projectProperties_overriddenBySystemProperty() {
Configuration configuration = new Configuration(mavenSessionMock);

assertThat(configuration.disable).isTrue();
assertThat(configuration.disableIfBranchRegex).isNull();
assertThat(configuration.disableIfBranchMatches).isNull();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void projectDependencyGraphMissing() throws Exception {

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

mockCurrentBranch("feature/cool-stuff");

Expand All @@ -176,7 +176,7 @@ public void enabledForBranch() throws Throwable {

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

mockCurrentBranch("develop");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void listWithUncommitted_disabled() throws Exception {
public void listWithUncommitted_excluded() throws Exception {
Path modifiedFilePath = modifyTrackedFile(repoPath);
projectProperties.setProperty(Property.uncommitted.prefixedName(), "true");
projectProperties.setProperty(Property.excludePathRegex.prefixedName(), Pattern.quote(repoPath.relativize(modifiedFilePath).toString()));
projectProperties.setProperty(Property.excludePathsMatching.prefixedName(), Pattern.quote(repoPath.relativize(modifiedFilePath).toString()));

assertThat(invokeUnderTest().contains(modifiedFilePath)).isFalse();
}
Expand All @@ -89,7 +89,7 @@ public void listWithUntracked_disabled() throws Exception {
public void listWithUntracked_excluded() throws Exception {
Path newFilePath = createNewUntrackedFile(repoPath);
projectProperties.setProperty(Property.untracked.prefixedName(), "true");
projectProperties.setProperty(Property.excludePathRegex.prefixedName(), Pattern.quote(repoPath.relativize(newFilePath).toString()));
projectProperties.setProperty(Property.excludePathsMatching.prefixedName(), Pattern.quote(repoPath.relativize(newFilePath).toString()));

assertThat(invokeUnderTest().contains(newFilePath)).isFalse();
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public void list_skipIfPathMatches_noMatches() throws Exception {

@Test
public void listExcluding() throws Exception {
projectProperties.setProperty(Property.excludePathRegex.prefixedName(), ".*file2.*");
projectProperties.setProperty(Property.excludePathsMatching.prefixedName(), ".*file2.*");
final Set<Path> expected = new HashSet<>(Arrays.asList(
Paths.get(repoPath + "/parent/child3/src/resources/file1"),
Paths.get(repoPath + "/parent/child4/pom.xml"),
Expand All @@ -148,7 +148,7 @@ public void listExcluding() throws Exception {

@Test
public void listIncluding() throws Exception {
projectProperties.setProperty(Property.includePathRegex.prefixedName(), ".*file2.*");
projectProperties.setProperty(Property.includePathsMatching.prefixedName(), ".*file2.*");
final Set<Path> expected = new HashSet<>(Arrays.asList(
Paths.get(repoPath + "/parent/child2/subchild2/src/resources/file2"),
Paths.get(repoPath + "/parent/child2/subchild2/src/resources/file22")
Expand All @@ -159,8 +159,8 @@ public void listIncluding() throws Exception {

@Test
public void listIncludingAndExcluding() throws Exception {
projectProperties.setProperty(Property.includePathRegex.prefixedName(), ".*file2.*");
projectProperties.setProperty(Property.excludePathRegex.prefixedName(), ".*file22.*");
projectProperties.setProperty(Property.includePathsMatching.prefixedName(), ".*file2.*");
projectProperties.setProperty(Property.excludePathsMatching.prefixedName(), ".*file22.*");
final Set<Path> expected = new HashSet<>(Arrays.asList(
Paths.get(repoPath + "/parent/child2/subchild2/src/resources/file2")
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ public void getValue_pluginProperties_overridesSystemPropertiesWithPrefixedShort

@Test
public void getValueOpt_empty() {
Optional<String> valueOpt = Property.disableIfBranchRegex.getValueOpt(NO_PROPS, NO_PROPS);
Optional<String> valueOpt = Property.disableIfBranchMatches.getValueOpt(NO_PROPS, NO_PROPS);

assertThat(valueOpt).isEqualTo(Optional.empty());
}

@Test
public void getValueOpt_notEmpty() {
Optional<String> valueOpt = Property.disableIfBranchRegex.getValueOpt(NO_PROPS, propsWith(Property.disableIfBranchRegex.prefixedName(), "master"));
Optional<String> valueOpt = Property.disableIfBranchMatches.getValueOpt(NO_PROPS, propsWith(Property.disableIfBranchMatches.prefixedName(), "master"));

assertThat(valueOpt).isEqualTo(Optional.of("master"));
}
Expand All @@ -173,7 +173,7 @@ public void checkProperties_ok() {
System.setProperty(Property.disable.prefixedName(), "");
System.setProperty(Property.disableBranchComparison.prefixedShortName(), "true");

Property.checkProperties(propsWith(Property.disableIfBranchRegex.name(), "master"),
Property.checkProperties(propsWith(Property.disableIfBranchMatches.name(), "master"),
propsWith(Property.buildAllIfNoChanges.prefixedName(), "true"));
// no exception
}
Expand Down

0 comments on commit b8916f6

Please sign in to comment.