commit ff265082fdc8cdb521d8bcf2d3b55fb6ea9797a6
parent bd68fc75d68036352460e8fcedacf1a6d904e68c
Author: Louis Burda <quent.burda@gmail.com>
Date: Thu, 11 Aug 2022 22:29:14 +0200
Always use target dir when supplied and not when absolute path
Diffstat:
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/patch.py b/patch.py
@@ -117,19 +117,10 @@ def main():
src_file = header_matches[i].group(1)
dst_file = header_matches[i].group(2)
- if src_file.split("/",1)[0] == "a" and dst_file.split("/",1)[0] == "b" \
- and not path.isdir("a") and not path.isdir("b"):
- if path.isfile(src_file.split("/",1)[1]):
- src_file = src_file.split("/",1)[1]
- dst_file = dst_file.split("/",1)[1]
- else:
- if not targetdir:
- if noprompt:
- print("[ERROR] Unknown patch prefix")
- sys.exit(1)
- else:
- targetdir = input("patch prefix: ")
+ if targetdir:
+ if src_file[0] != "/":
src_file = targetdir + "/" + src_file.split("/",1)[1]
+ if dst_file[0] != "/":
dst_file = targetdir + "/" + dst_file.split("/",1)[1]
print("[PATCH] Applying patch from {} to {}".format(src_file, dst_file))