From 53e90d0f4a178139f4f10ff41bbda4bbc944a6ac Mon Sep 17 00:00:00 2001 From: Joseph Eng Date: Mon, 15 Jul 2024 19:22:48 -0700 Subject: [PATCH] Fix format-patch Clear the patch directory first Use shutil.move instead to handle different filesystems for temp dir and allwpilib --- upstream_utils/upstream_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upstream_utils/upstream_utils.py b/upstream_utils/upstream_utils.py index 54e47dd245b..233daa23446 100644 --- a/upstream_utils/upstream_utils.py +++ b/upstream_utils/upstream_utils.py @@ -393,10 +393,16 @@ def format_patch(self, tag=None): print( f"WARNING: Patch directory {patch_dest} does not exist", file=sys.stderr ) + else: + shutil.rmtree(patch_dest) + is_first = True for f in os.listdir(): if f.endswith(".patch"): - os.rename(f, os.path.join(patch_dest, f)) + if is_first: + os.mkdir(patch_dest) + is_first = False + shutil.move(f, patch_dest) self.replace_tag(tag)