diff options
author | Nassim Jahnke <[email protected]> | 2024-01-22 21:04:08 +0100 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2024-01-22 21:13:10 +0100 |
commit | 25013d997057eb89471d285db2a4b40acde6272d (patch) | |
tree | 5a63d965f7e6fae42e73593eadf312de7a354119 /scripts | |
parent | 9eb0b381571a2a3c8db78ac938cb596d3890a08f (diff) | |
download | Paper-25013d997057eb89471d285db2a4b40acde6272d.tar.gz Paper-25013d997057eb89471d285db2a4b40acde6272d.zip |
[ci skip] Move some disruptive patches back
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/moveback.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/moveback.py b/scripts/moveback.py new file mode 100644 index 0000000000..744f101a1e --- /dev/null +++ b/scripts/moveback.py @@ -0,0 +1,44 @@ +import os +import sys + +# Use inside of server patch dir +# py ../../scripts/moveback.py '' +patch_target = 1038 # TODO: Update this + + +def increment_number(filename): + current_number = int(filename[:4]) + new_number = current_number + 1 + return f"{new_number:04d}-{filename[5:]}" + + +if len(sys.argv) != 2: + print("python moveback.py '<commit title>'") + sys.exit(1) + +input_string = sys.argv[1].replace(' ', '-').lower() +if len(input_string) < 5: + print("Commit title is too short") + sys.exit(1) + +matching_files = [file for file in os.listdir() if input_string in file.lower()] + +if len(matching_files) == 0: + print("No file found matching the given string") + sys.exit(1) + +matching_file = matching_files[0] +print(f"Found: {matching_file}") + +# Move all files after the target one up +for file in os.listdir(): + num = int(file[:4]) + if num >= patch_target: + new_filename = increment_number(file) + os.rename(file, new_filename) + print(f"Renamed {file} to {new_filename}") + +# Rename the file to the target +new_filename = f"{patch_target:04d}-{matching_file[5:]}" +os.rename(matching_file, new_filename) +print(f"Renamed {matching_file} to {new_filename}") |