Skip to content

Commit

Permalink
Additionally strip bazel/blaze-out from paths in CompilerOptions#conf…
Browse files Browse the repository at this point in the history
…ormanceRemoveRegexFromPath, and change this to a getter/setter.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=262409485
  • Loading branch information
adob authored and brad4d committed Aug 10, 2019
1 parent c096d26 commit d9a0084
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/com/google/javascript/jscomp/CompilerOptions.java
Expand Up @@ -1191,7 +1191,16 @@ public boolean getAssumeGettersArePure() {
* <p>You can use this to make absolute paths relative to the root of your source tree. This is
* useful to work around CI and build systems that use absolute paths.
*/
Pattern conformanceRemoveRegexFromPath = Pattern.compile(".*?google3/");
private Optional<Pattern> conformanceRemoveRegexFromPath =
Optional.of(Pattern.compile("^((.*/)?google3/)?((^/)?(blaze|bazel)-out/[^/]+/bin/)?"));

public void setConformanceRemoveRegexFromPath(Optional<Pattern> pattern) {
conformanceRemoveRegexFromPath = pattern;
}

public Optional<Pattern> getConformanceRemoveRegexFromPath() {
return conformanceRemoveRegexFromPath;
}

/** For use in {@link CompilationLevel#WHITESPACE_ONLY} mode, when using goog.module. */
boolean wrapGoogModulesForWhitespaceOnly = true;
Expand Down
6 changes: 5 additions & 1 deletion src/com/google/javascript/jscomp/ConformanceRules.java
Expand Up @@ -250,7 +250,11 @@ protected abstract ConformanceResult checkConformance(
/** Returns the first Whitelist entry that matches the given path, and null otherwise. */
@Nullable
private Whitelist findWhitelistForPath(String path) {
path = compiler.getOptions().conformanceRemoveRegexFromPath.matcher(path).replaceFirst("");
Optional<Pattern> pathRegex = compiler.getOptions().getConformanceRemoveRegexFromPath();
if (pathRegex.isPresent()) {
path = pathRegex.get().matcher(path).replaceFirst("");
}

for (Whitelist whitelist : whitelists) {
if (whitelist.matches(path)) {
return whitelist;
Expand Down

0 comments on commit d9a0084

Please sign in to comment.