Skip to content

Commit 5e82edc

Browse files
authored
Leaving the version block at the top of the PDL file (#16448)
* Leaving the version block at the top of pdl file
1 parent a99c253 commit 5e82edc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/update_cdp.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ def old_chrome(chrome_milestone):
6565

6666

6767
def flatten_browser_pdl(file_path, chrome_version):
68-
"""Fetches all included domain .pdl files and concatenates them."""
68+
"""Preserves the version block and concatenates all included domain .pdl files."""
6969
with open(file_path, "r") as file:
7070
content = file.read()
71+
# Extract version block
72+
version_match = re.search(r"(version\s+major\s+\d+\s+minor\s+\d+)", content)
73+
version_block = version_match.group(1) + "\n\n" if version_match else ""
7174
# Find all include lines
7275
includes = re.findall(r"include domains/([A-Za-z0-9_]+\.pdl)", content)
7376
base_url = f"https://raw.githubusercontent.com/chromium/chromium/{chrome_version}/third_party/blink/public/devtools_protocol/domains/"
@@ -76,9 +79,9 @@ def flatten_browser_pdl(file_path, chrome_version):
7679
url = base_url + domain_file
7780
response = http.request("GET", url)
7881
concatenated += response.data.decode("utf-8") + "\n"
79-
# Overwrite the file with concatenated domains
82+
# Overwrite the file with version block + concatenated domains
8083
with open(file_path, "w") as file:
81-
file.write(concatenated)
84+
file.write(version_block + concatenated)
8285

8386

8487
def add_pdls(chrome_milestone):

0 commit comments

Comments
 (0)