From 2d3f108bb67a3f2cefaa538e86a2f82f1387d20d Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sat, 7 Jun 2025 04:10:27 +0200 Subject: [PATCH] maintainers/scripts/remove-old-aliases: handle `inherit (x) y;` Man this script is not very nice --- maintainers/scripts/remove-old-aliases.py | 40 ++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/maintainers/scripts/remove-old-aliases.py b/maintainers/scripts/remove-old-aliases.py index fcef5c58a631..78a2fb0ab6ac 100755 --- a/maintainers/scripts/remove-old-aliases.py +++ b/maintainers/scripts/remove-old-aliases.py @@ -70,7 +70,10 @@ def get_date_lists( ): continue - if "=" not in line: + if line.lstrip().startswith("inherit (") and ";" in line: + if not only_throws: + date_older_list.append(line) + elif "=" not in line: date_sep_line_list.append(f"{lineno:>5} {line}") # 'if' lines could be complicated elif "if " in line and "if =" not in line: @@ -99,18 +102,31 @@ def convert_to_throw(date_older_list: list[str]) -> list[tuple[str, str]]: converted_list = [] for line in date_older_list.copy(): indent: str = " " * (len(line) - len(line.lstrip())) - before_equal = "" - after_equal = "" - try: - before_equal, after_equal = (x.strip() for x in line.split("=", maxsplit=2)) - except ValueError as err: - print(err, line, "\n") - date_older_list.remove(line) - continue - alias = before_equal - alias_unquoted = before_equal.strip('"') - replacement = next(x.strip(";:") for x in after_equal.split()) + if "=" not in line: + assert "inherit (" in line + before, sep, after = line.partition("inherit (") + inside, sep, after = after.partition(")") + if not sep: + print(f"FAILED ON {line}") + continue + alias, *_ = after.strip().split(";")[0].split() + replacement = f"{inside.strip()}.{alias}" + + else: + before_equal = "" + after_equal = "" + try: + before_equal, after_equal = (x.strip() for x in line.split("=", maxsplit=2)) + except ValueError as err: + print(err, line, "\n") + date_older_list.remove(line) + continue + + alias = before_equal + replacement = next(x.strip(";:") for x in after_equal.split()) + + alias_unquoted = alias.strip('"') replacement = replacement.removeprefix("pkgs.") converted = (