about summary refs log tree commit diff
path: root/nixpkgs/maintainers/scripts/remove-old-aliases.py
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-03-30 13:30:47 +0000
committerAlyssa Ross <hi@alyssa.is>2022-03-31 10:13:20 +0000
commitf2e61678de300336b3666afd19af7565efb0c4cf (patch)
tree49f6906c9d557f7fdd58257ff85ec17fc4495f31 /nixpkgs/maintainers/scripts/remove-old-aliases.py
parentf920d5e07c29a9aa1b77d9b88bd604cf1a1f3664 (diff)
parent00e27c78d3d2de6964096ceee8d70e5b487365e3 (diff)
downloadnixlib-f2e61678de300336b3666afd19af7565efb0c4cf.tar
nixlib-f2e61678de300336b3666afd19af7565efb0c4cf.tar.gz
nixlib-f2e61678de300336b3666afd19af7565efb0c4cf.tar.bz2
nixlib-f2e61678de300336b3666afd19af7565efb0c4cf.tar.lz
nixlib-f2e61678de300336b3666afd19af7565efb0c4cf.tar.xz
nixlib-f2e61678de300336b3666afd19af7565efb0c4cf.tar.zst
nixlib-f2e61678de300336b3666afd19af7565efb0c4cf.zip
Merge commit '00e27c78d3d2de6964096ceee8d70e5b487365e3'
Conflicts:
	nixpkgs/nixos/modules/system/boot/systemd.nix
	nixpkgs/pkgs/applications/networking/browsers/firefox/common.nix
	nixpkgs/pkgs/applications/version-management/git-and-tools/cgit/common.nix
	nixpkgs/pkgs/applications/version-management/git-and-tools/cgit/default.nix
	nixpkgs/pkgs/applications/version-management/git-and-tools/cgit/pink.nix
	nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/maintainers/scripts/remove-old-aliases.py')
-rwxr-xr-xnixpkgs/maintainers/scripts/remove-old-aliases.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/nixpkgs/maintainers/scripts/remove-old-aliases.py b/nixpkgs/maintainers/scripts/remove-old-aliases.py
index 5d9398feaa25..c5629c829594 100755
--- a/nixpkgs/maintainers/scripts/remove-old-aliases.py
+++ b/nixpkgs/maintainers/scripts/remove-old-aliases.py
@@ -28,6 +28,11 @@ def process_args() -> argparse.Namespace:
         default=1,
         help="operate on aliases older than $year-$month",
     )
+    arg_parser.add_argument(
+        "--only-throws",
+        action="store_true",
+        help="only operate on throws. e.g remove throws older than $date",
+    )
     arg_parser.add_argument("--file", required=True, type=Path, help="alias file")
     arg_parser.add_argument(
         "--dry-run", action="store_true", help="don't modify files, only print results"
@@ -36,7 +41,7 @@ def process_args() -> argparse.Namespace:
 
 
 def get_date_lists(
-    txt: list[str], cutoffdate: datetimedate
+    txt: list[str], cutoffdate: datetimedate, only_throws: bool
 ) -> tuple[list[str], list[str], list[str]]:
     """get a list of lines in which the date is older than $cutoffdate"""
     date_older_list: list[str] = []
@@ -57,7 +62,11 @@ def get_date_lists(
                 except ValueError:
                     continue
 
-        if my_date is None or my_date > cutoffdate:
+        if (
+            my_date is None
+            or my_date > cutoffdate
+            or "preserve, reason:" in line.lower()
+        ):
             continue
 
         if "=" not in line:
@@ -67,7 +76,7 @@ def get_date_lists(
             print(f"RESOLVE MANUALLY {line}")
         elif "throw" in line:
             date_older_throw_list.append(line)
-        else:
+        elif not only_throws:
             date_older_list.append(line)
 
     return (
@@ -160,6 +169,7 @@ def main() -> None:
     """main"""
     args = process_args()
 
+    only_throws = args.only_throws
     aliasfile = Path(args.file).absolute()
     cutoffdate = (datetime.strptime(f"{args.year}-{args.month}-01", "%Y-%m-%d")).date()
 
@@ -170,13 +180,12 @@ def main() -> None:
     date_older_throw_list: list[str] = []
 
     date_older_list, date_sep_line_list, date_older_throw_list = get_date_lists(
-        txt, cutoffdate
+        txt, cutoffdate, only_throws
     )
 
     converted_to_throw: list[tuple[str, str]] = []
-    converted_to_throw = convert_to_throw(date_older_list)
-
     if date_older_list:
+        converted_to_throw = convert_to_throw(date_older_list)
         print(" Will be converted to throws. ".center(100, "-"))
         for l_n in date_older_list:
             print(l_n)