Skip to content

Commit

Permalink
Disallow ! patterns in build_ignore. (Cherry-pick of pantsbuild#1…
Browse files Browse the repository at this point in the history
…5366) (pantsbuild#15367)

As discussed in pantsbuild#15336, including a negation in `build_ignore` (unlike `pants_ignore`, which is interpreted directly by the `ignore` crate) amounts to adding an include pattern, which will not work as expected.

Closes pantsbuild#15336.

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
stuhood authored May 6, 2022
1 parent 18e74e5 commit e8b0296
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,10 +1316,9 @@ class GlobalOptions(BootstrapOptions, Subsystem):
build_ignore = StrListOption(
"--build-ignore",
help=(
"Paths to ignore when identifying BUILD files.\n\n"
"Path globs or literals to ignore when identifying BUILD files.\n\n"
"This does not affect any other filesystem operations; use `--pants-ignore` for "
"that instead.\n\n"
"Patterns use the gitignore pattern syntax (https://git-scm.com/docs/gitignore)."
"that instead."
),
advanced=True,
)
Expand Down Expand Up @@ -1463,6 +1462,13 @@ def validate_remote_headers(opt_name: str) -> None:
validate_remote_headers("remote_execution_headers")
validate_remote_headers("remote_store_headers")

illegal_build_ignores = [i for i in opts.build_ignore if i.startswith("!")]
if illegal_build_ignores:
raise OptionsError(
"The `--build-ignore` option does not support negated globs, but was "
f"given: {illegal_build_ignores}."
)

@staticmethod
def create_py_executor(bootstrap_options: OptionValueContainer) -> PyExecutor:
rule_threads_max = (
Expand Down

0 comments on commit e8b0296

Please sign in to comment.