Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved factor selection to allow multiple uses of -f for "OR" and to allow hyphenated factors #2786

Merged
merged 9 commits into from Dec 29, 2022

Commits on Dec 28, 2022

  1. Enable multiple uses of '-f' meaning 'OR'

    Previously, when `-f` was passed, it overwrote the last value. The
    result was that `-f foo -f bar` was equivalent to only passing
    `-f bar`. Under the new behavior, `-f foo -f bar` combines `foo` and
    `bar` as selection criteria, using OR-semantics. Envs matching
    `foo OR bar` will be selected.
    
    The existing multi-value argument behavior for `-f` is retained, in
    which `-f foo bar` means `foo AND bar`. The behaviors can be combined
    to express a variety of environment selections which were not
    previously possible in a single invocation. e.g. `-f foo bar -f baz`
    meaning `(foo AND bar) OR baz`.
    
    No existing tests fail, and the new behavior is checked by a new test.
    The help message for `-f` is updated.
    sirosen committed Dec 28, 2022
    Copy the full SHA
    71ed520 View commit details
    Browse the repository at this point in the history
  2. Allow factors to be passed hyphenated

    The existing parsing of factors allows multiple factors to be selected
    by passing them as multiple arguments to the `-f` flag. For example,
    `-f foo bar` to pass both `foo` and `bar` as factors. This can now be
    passed equivalently using `-f foo-bar`. The meaning of this
    usage is identical to `-f foo bar`.
    
    A new test checks the behavior, and very closely mirrors the existing
    `-f` selection test so that their outputs are exactly equivalent.
    sirosen committed Dec 28, 2022
    Copy the full SHA
    a20160d View commit details
    Browse the repository at this point in the history
  3. Make factor tests parametrized & apply pre-commit

    These three tests are nearly identical in structure, and rely upon the
    same project configuration. Convert from three distinct test cases to
    a single parametrized test.
    
    Also apply pre-commit, which does some mild reformatting.
    sirosen committed Dec 28, 2022
    Copy the full SHA
    08092bf View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    a8e9b15 View commit details
    Browse the repository at this point in the history

Commits on Dec 29, 2022

  1. Copy the full SHA
    826e2a9 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    2be500b View commit details
    Browse the repository at this point in the history
  3. Improve env selection with factors: perf and types

    - use tuple instead of list for immutable data
    - use `continue` and `break` to skip unnecessary loop iterations
    sirosen committed Dec 29, 2022
    Copy the full SHA
    6c69190 View commit details
    Browse the repository at this point in the history
  4. Cleanup factor selection tests

    - convert args from list[str] to tuple[str, ...]
    - reformat str concat into a `.format()` usage
    sirosen committed Dec 29, 2022
    Copy the full SHA
    b398ccf View commit details
    Browse the repository at this point in the history
  5. Remove unreachable factor selection check

    This check cannot be reached because it relies on an impossible
    combination of factors and labels.
    sirosen committed Dec 29, 2022
    Copy the full SHA
    9984d91 View commit details
    Browse the repository at this point in the history