Skip to content

Commit bdec440

Browse files
committed
fix(register): Exact name match when locating package line in YAML file
startswith() matched 'Keyfactor.Workflows.IWorkflowStep' when searching for 'Keyfactor.Workflows', writing the new version to the wrong package. Replaced with a regex that requires the name to be followed only by optional whitespace or a comment.
1 parent 10c8397 commit bdec440

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

scripts/sync_nuget.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import sys
2727
from pathlib import Path
2828

29+
import re
30+
2931
import click
3032
import requests
3133
import yaml
@@ -425,7 +427,8 @@ def _write_versions_to_file(
425427

426428
if existing:
427429
pkg_line = next(
428-
(i for i, l in enumerate(lines) if l.strip().lstrip("- ").startswith(f"name: {name}")),
430+
(i for i, l in enumerate(lines)
431+
if re.match(rf'^\s*-\s+name:\s+{re.escape(name)}\s*(?:#.*)?$', l)),
429432
None,
430433
)
431434
if pkg_line is None:

0 commit comments

Comments
 (0)