Skip to content

Commit 5f48f72

Browse files
committed
refs
1 parent 49fd0fa commit 5f48f72

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Tools/build/compute-changes.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import subprocess
5+
import sys
56
from dataclasses import dataclass
67
from collections.abc import Set
78
from pathlib import Path
@@ -26,9 +27,9 @@ class Outputs:
2627
run_win_msi: bool = False
2728

2829

29-
def compute_changes():
30+
def compute_changes(ref_a: str = "main", ref_b: str = "HEAD"):
3031
target_branch = get_git_base_branch()
31-
changed_files = get_changed_files()
32+
changed_files = get_changed_files(ref_a, ref_b)
3233
outputs = process_changed_files(changed_files)
3334
outputs = process_target_branch(outputs, target_branch)
3435

@@ -54,7 +55,7 @@ def compute_changes():
5455
write_github_output(outputs)
5556

5657

57-
def get_changed_files(ref_a: str = "main", ref_b: str = "HEAD") -> Set[Path]:
58+
def get_changed_files(ref_a: str, ref_b: str) -> Set[Path]:
5859
"""List the files changed between two Git refs, filtered by change type."""
5960
changed_files_result = subprocess.run(
6061
("git", "diff", "--name-only", f"{ref_a}...{ref_b}", "--"),
@@ -176,4 +177,9 @@ def bool_lower(value: bool, /) -> str:
176177

177178

178179
if __name__ == "__main__":
179-
compute_changes()
180+
try:
181+
base_ref, pr_ref = sys.argv[1:3]
182+
except ValueError:
183+
compute_changes()
184+
else:
185+
compute_changes(base_ref, pr_ref)

0 commit comments

Comments
 (0)