mirror of
https://github.com/apache/airflow.git
synced 2026-11-04 07:12:48 +00:00
Keep breeze verify working when dry-run is on (#75713)
With dry-run on, run_command skips every command and returns empty output. breeze verify only reads git state to list the checks a change needs, so skipping those queries made it crash with an IndexError instead of answering.
This commit is contained in:
1 parent
de5798196d
commit
a5ff71dffd
2 files changed
+24
-1
No files matched your search
@@ -42,7 +42,15 @@ APACHE_AIRFLOW_URL = re.compile(r"github\.com[:/]apache/airflow(\.git)?/?$")
|
||||
|
||||
|
||||
def _run_git(*args: str) -> CompletedProcess:
|
||||
return run_command(["git", *args], capture_output=True, text=True, check=False, cwd=AIRFLOW_ROOT_PATH)
|
||||
# Read-only queries: dry-run would skip them and return empty output.
|
||||
return run_command(
|
||||
["git", *args],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
cwd=AIRFLOW_ROOT_PATH,
|
||||
dry_run_override=False,
|
||||
)
|
||||
|
||||
|
||||
def find_default_base_ref() -> str | None:
|
||||
|
||||
@@ -32,6 +32,7 @@ from airflow_breeze.commands.verify_commands import (
|
||||
has_merged_commits_missing_from,
|
||||
verify,
|
||||
)
|
||||
from airflow_breeze.utils.shared_options import set_dry_run
|
||||
|
||||
ANSI = re.compile(r"\x1b\[[0-9;]*m")
|
||||
|
||||
@@ -360,3 +361,17 @@ def test_merged_commits_missing_from_the_base_are_warned_about(mock_files, mock_
|
||||
assert warning in " ".join(ANSI.sub("", stream).split())
|
||||
if as_json:
|
||||
assert json.loads(result.stdout)["base_ref"] == "upstream/main"
|
||||
|
||||
|
||||
@patch(
|
||||
"airflow_breeze.utils.run_utils.subprocess.run",
|
||||
autospec=True,
|
||||
side_effect=[
|
||||
CompletedProcess(args=[], returncode=0, stdout="abc123\n", stderr=""),
|
||||
CompletedProcess(args=[], returncode=0, stdout="file.py\n", stderr=""),
|
||||
CompletedProcess(args=[], returncode=0, stdout="", stderr=""),
|
||||
],
|
||||
)
|
||||
def test_changed_files_are_computed_in_dry_run(mock_subprocess_run):
|
||||
set_dry_run(True)
|
||||
assert get_changed_files_against("main") == ("file.py",)
|
||||
Reference in new issue
Block a user