Skip to content

Commit

Permalink
Make --file command in static-checks autocomplete file name (#23896)
Browse files Browse the repository at this point in the history
The --verbose and --dry-dun commands caused n --files command to fail
and the flag was "artifficial" -it was equivalent to bool flag.
the actual files were taken  from arguments.

This PR fixes it by turning the arguments into multiple ``--file``
commands  - each with its own completioin for local files.

(cherry picked from commit 1d53bec)
  • Loading branch information
potiuk authored and ephraimbuddy committed May 30, 2022
1 parent 870d091 commit 188afd2
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 70 deletions.
4 changes: 2 additions & 2 deletions STATIC_CODE_CHECKS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,13 @@ Run the ``flake8`` check for the ``tests.core.py`` file with verbose output:

.. code-block:: bash
breeze static-check --type run-flake8 --files tests/core.py --verbose
breeze static-check --type run-flake8 --file tests/core.py --verbose
Run the ``flake8`` check for the ``tests.core`` package with verbose output:

.. code-block:: bash
breeze static-check --type run-flake8 --files tests/core/* --verbose
breeze static-check --type run-flake8 --file tests/core/* --verbose
Run all tests for the currently staged files:

Expand Down
15 changes: 8 additions & 7 deletions dev/breeze/src/airflow_breeze/commands/developer_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os
import sys
from typing import Optional, Tuple
from typing import Iterable, Optional, Tuple

import rich_click as click

Expand Down Expand Up @@ -199,7 +199,7 @@
"name": "Pre-commit flags",
"options": [
"--type",
"--files",
"--file",
"--all-files",
"--show-diff-on-failure",
"--last-commit",
Expand Down Expand Up @@ -438,8 +438,8 @@ def build_docs(
type=BetterChoice(PRE_COMMIT_LIST),
multiple=True,
)
@click.option('-a', '--all-files', help="Run checks on all files.", is_flag=True)
@click.option('-f', '--files', help="List of files to run the checks on.", multiple=True)
@click.option('-a', '--all-files', help="Run checks on all files.")
@click.option('-f', '--file', help="List of files to run the checks on.", type=click.Path(), multiple=True)
@click.option(
'-s', '--show-diff-on-failure', help="Show diff for files modified by the checks.", is_flag=True
)
Expand Down Expand Up @@ -469,7 +469,7 @@ def static_checks(
last_commit: bool,
commit_ref: str,
type: Tuple[str],
files: bool,
file: Iterable[str],
precommit_args: Tuple,
):
assert_pre_commit_installed(verbose=verbose)
Expand All @@ -488,10 +488,11 @@ def static_checks(
command_to_execute.extend(["--from-ref", "HEAD^", "--to-ref", "HEAD"])
if commit_ref:
command_to_execute.extend(["--from-ref", f"{commit_ref}^", "--to-ref", f"{commit_ref}"])
if files:
command_to_execute.append("--files")
if verbose or dry_run:
command_to_execute.append("--verbose")
if file:
command_to_execute.append("--files")
command_to_execute.extend(file)
if precommit_args:
command_to_execute.extend(precommit_args)
env = os.environ.copy()
Expand Down
2 changes: 1 addition & 1 deletion images/breeze/output-commands-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43bc980dd30f21c6979990470870a936
e275b745e83c5e5f4fc2a54677ab7e0d
Loading

0 comments on commit 188afd2

Please sign in to comment.