From 81acd03f8965b5a3a0fb1cc3fe436855181775ee Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Mon, 4 Apr 2022 15:18:25 +0200 Subject: [PATCH] tools: Better dependency fixing Lines like 'deps = [ "foo" ]' would fail to be fixed. Just insert the new dependencies in front and let the formatter have fun with this after. Bug: None Change-Id: I747925cd0a1de93715a00b9ff3490b555f237e97 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257906 Reviewed-by: Mirko Bonadei Auto-Submit: Florent Castelli Commit-Queue: Florent Castelli Cr-Commit-Position: refs/heads/main@{#36429} --- tools_webrtc/gn_check_autofix.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools_webrtc/gn_check_autofix.py b/tools_webrtc/gn_check_autofix.py index 1a9389806a..3895dc9abe 100644 --- a/tools_webrtc/gn_check_autofix.py +++ b/tools_webrtc/gn_check_autofix.py @@ -81,11 +81,10 @@ def FixErrors(filename, missing_deps, deleted_sources): for dep in missing_deps[target]) + ']\n') + line indentation_level = None - elif line.strip().startswith('deps'): - is_empty_deps = line.strip() == 'deps = []' - line = 'deps = [\n' if is_empty_deps else line - line += ''.join(' "' + dep + '",\n' for dep in missing_deps[target]) - line += ']\n' if is_empty_deps else '' + elif line.strip().startswith('deps = ['): + joined_deps = ''.join(' "' + dep + '",\n' + for dep in missing_deps[target]) + line = line.replace('deps = [', 'deps = [' + joined_deps) indentation_level = None if line.strip() not in deleted_sources: