Skip to content

Commit

Permalink
Improved BlazeTargetFilter regex to match more target names (#6021)
Browse files Browse the repository at this point in the history
Changed the regex used by BlazeTargetFilter to include more valid target names based on https://bazel.build/concepts/labels#target-names
  • Loading branch information
LeFrosch authored Feb 12, 2024
1 parent 86ce82c commit 8a82231
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
/** Parse blaze targets in streamed output. */
public class BlazeTargetFilter implements Filter {

// See Bazel's LabelValidator class. Whitespace character intentionally not included here.
private static final String PACKAGE_NAME_CHARS = "a-zA-Z0-9/\\-\\._$()";
private static final String TARGET_CHARS = "a-zA-Z0-9+,=~#()$_@\\-/";
// See Bazel's LabelValidator class. Whitespace character and ' intentionally not included here.
private static final String PACKAGE_NAME_CHARS = "a-zA-Z0-9/\\-\\._$()@";
private static final String TARGET_CHARS = "a-zA-Z0-9!%@^_\"#$&()*\\-+,;<=>?\\[\\]{|}~/\\.";

// ignore '//' preceded by text (e.g. https://...)
// format: ([@external_workspace]//package:rule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public void testQuotedTarget() {

@Test
public void testUnusualCharsInTarget() {
String line = "Something //Package-._$():T0+,=~#target_@name something else";
assertThat(findMatch(line)).isEqualTo("//Package-._$():T0+,=~#target_@name");
String line = "Something //Package-._$()@:T0!%^_\"#$&()*-+,;<=>?[]{|}~/.target_@name something else";
assertThat(findMatch(line)).isEqualTo("//Package-._$()@:T0!%^_\"#$&()*-+,;<=>?[]{|}~/.target_@name");
}

@Test
Expand Down

0 comments on commit 8a82231

Please sign in to comment.