mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 02:31:29 +00:00
Fix possibly unbound Body by assigning preassigning them the else case and overriding them in the if case.
The current case will work until eiether the has_chunk_header above or below the _process_diff function changes, and then it will cause runtime crash as one cannot concat string and None. Change-Id: I81737328f609e636bcee5087a2bc4aa96a6a6964 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7260374 Reviewed-by: Brian Egizi <begizi@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Alex Ovsienko <ovsienko@google.com>
This commit is contained in:
@@ -84,11 +84,10 @@ def _process_diff(diff: str, src_root: str, dst_root: str) -> str:
|
||||
return ""
|
||||
|
||||
has_chunk_header = HEADER_DELIMITER in diff
|
||||
|
||||
header, body = diff, ""
|
||||
if has_chunk_header:
|
||||
header, body = diff.split(HEADER_DELIMITER, maxsplit=1)
|
||||
else:
|
||||
# Only the file mode changed.
|
||||
header = diff
|
||||
|
||||
norm_src = src_root.rstrip(os.sep)
|
||||
norm_dst = dst_root.rstrip(os.sep)
|
||||
|
||||
Reference in New Issue
Block a user