Skip to content

Commit

Permalink
(CI)(merge-known-hosts) allow multiple leading_comment_lines
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Jun 10, 2024
1 parent 4c89ca4 commit 1eda2b8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ci/ssh-merge-known_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def truncate(s: str, w: int) -> str:
hostkeys: Dict[Tuple[str, str], Dict[str, Union[Set[str], str]]] = defaultdict(key_dict_factory)
for kfile in args.files:
with open(kfile) as kf:
leading_comment_line = None
leading_comment_lines = set()
for line in kf:
if line[0] == "#":
leading_comment_line = line
leading_comment_lines.add(line)
continue
line_splitted: List[str] = line.rstrip().split(" ")
marker: Optional[str] = None
Expand All @@ -92,9 +92,9 @@ def truncate(s: str, w: int) -> str:
comment = " ".join(line_splitted)
hostkeys[unique_key]["comments"].add(comment)
hostkeys[unique_key]["hosts"].update(hosts)
if leading_comment_line is not None:
hostkeys[unique_key]["leading_comment_lines"].add(leading_comment_line)
leading_comment_line = None
if leading_comment_lines:
hostkeys[unique_key]["leading_comment_lines"].update(leading_comment_lines)
leading_comment_lines = set()
if marker is not None:
if hostkeys[unique_key]["marker"] is not None:
raise ValueError(f"Multiple markers for same key: {truncate(str(unique_key), 50)}")
Expand Down

0 comments on commit 1eda2b8

Please sign in to comment.