-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apply_fixes: Support cquery and custom bazel arguments
Until now the apply_fixes script by default uses `bazel query` to find missing dependencies. A project might use select statements to exchange dependencies. In such cases one should use `bazel cquery` to allow the apply_fixes script to understand the dependency tree properly. This also requires the user being able to provide arguments to `bazel cquery`. Refactoring incorporated into this: - Due to the missing dependency discover logic increasing in complexity, we spit it into a separate module - We output commands as a single string in verbose mode to ease copying them for debugging
- Loading branch information
Showing
16 changed files
with
420 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from src.apply_fixes.utils import execute_and_capture | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
from subprocess import CompletedProcess | ||
|
||
|
||
class BazelQuery: | ||
def __init__(self, workspace: Path, use_cquery: bool, query_args: list[str], startup_args: list[str]) -> None: | ||
self._workspace = workspace | ||
self._use_cquery = use_cquery | ||
self._query_args = query_args | ||
self._startup_args = startup_args | ||
|
||
def execute(self, query: str, args: list[str]) -> CompletedProcess: | ||
cmd = [ | ||
"bazel", | ||
*self._startup_args, | ||
"cquery" if self._use_cquery else "query", | ||
*self._query_args, | ||
*args, | ||
query, | ||
] | ||
return execute_and_capture(cmd=cmd, cwd=self._workspace) | ||
|
||
@property | ||
def uses_cquery(self) -> bool: | ||
return self._use_cquery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.