From eb05d2068cf3830556dbc1e47962a4e67d7fadc1 Mon Sep 17 00:00:00 2001 From: Ken Greiner Date: Mon, 10 Jan 2022 11:09:34 -0500 Subject: [PATCH 1/2] #20 - Fix path replace problem --- review.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/review.py b/review.py index 481c389..67c7fe0 100755 --- a/review.py +++ b/review.py @@ -350,11 +350,15 @@ def main( original_directory = compile_commands[0]["directory"] # directory should either end with the build directory, - # unless it's '.', in which case use all of directory + # unless it's '.', in which case use all of the directory, + # excluding the trailing /. if original_directory.endswith(args.build_dir): build_dir_index = -(len(args.build_dir) + 1) elif args.build_dir == ".": - build_dir_index = -1 + if (original_directory.endswith("/")): + build_dir_index = -1 + else: + build_dir_index = len(original_directory) + 1 else: raise RuntimeError( f"compile_commands.json contains absolute paths that I don't know how to deal with: '{original_directory}'" From abc3f0b984c18cf16931774f2f0489afd866cb89 Mon Sep 17 00:00:00 2001 From: Ken Greiner Date: Mon, 10 Jan 2022 14:05:57 -0500 Subject: [PATCH 2/2] #20 author revisions --- review.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/review.py b/review.py index 67c7fe0..58b7188 100755 --- a/review.py +++ b/review.py @@ -350,21 +350,17 @@ def main( original_directory = compile_commands[0]["directory"] # directory should either end with the build directory, - # unless it's '.', in which case use all of the directory, - # excluding the trailing /. + # unless it's '.', in which case use all of directory if original_directory.endswith(args.build_dir): build_dir_index = -(len(args.build_dir) + 1) + basedir = original_directory[:build_dir_index] elif args.build_dir == ".": - if (original_directory.endswith("/")): - build_dir_index = -1 - else: - build_dir_index = len(original_directory) + 1 + basedir = original_directory else: raise RuntimeError( f"compile_commands.json contains absolute paths that I don't know how to deal with: '{original_directory}'" ) - basedir = original_directory[:build_dir_index] newbasedir = os.getcwd() print(f"Replacing '{basedir}' with '{newbasedir}'", flush=True)