diff --git a/clang-tools-extra/clang-tidy/rename_check.py b/clang-tools-extra/clang-tidy/rename_check.py --- a/clang-tools-extra/clang-tidy/rename_check.py +++ b/clang-tools-extra/clang-tidy/rename_check.py @@ -15,6 +15,7 @@ import io import os import re +import subprocess def replaceInFileRegex(fileName, sFrom, sTo): if sFrom == sTo: @@ -71,7 +72,7 @@ return fileName newFileName = fileName.replace(sFrom, sTo) print("Renaming '%s' -> '%s'..." % (fileName, newFileName)) - os.rename(fileName, newFileName) + subprocess.check_call(["git", "mv", fileName, newFileName]) return newFileName @@ -93,12 +94,9 @@ def getListOfFiles(clang_tidy_path): - files = glob.glob(os.path.join(clang_tidy_path, '*')) - for dirname in files: - if os.path.isdir(dirname): - files += glob.glob(os.path.join(dirname, '*')) + files = glob.glob(os.path.join(clang_tidy_path, '**'), recursive=True) files += glob.glob(os.path.join(clang_tidy_path, '..', 'test', - 'clang-tidy', '*')) + 'clang-tidy', 'checkers', '**'), recursive=True) files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs', 'clang-tidy', 'checks', '*')) return [filename for filename in files if os.path.isfile(filename)] @@ -273,10 +271,12 @@ deleteMatchingLines(os.path.join(old_module_path, modulecpp), '\\b' + check_name_camel + '|\\b' + args.old_check_name) + old_check_filename = '-'.join(args.old_check_name.split('-')[1:]) + new_check_filename = '-'.join(args.new_check_name.split('-')[1:]) + for filename in getListOfFiles(clang_tidy_path): originalName = filename - filename = fileRename(filename, args.old_check_name, - args.new_check_name) + filename = fileRename(filename, old_check_filename, new_check_filename) filename = fileRename(filename, check_name_camel, new_check_name_camel) replaceInFile(filename, generateCommentLineHeader(originalName), generateCommentLineHeader(filename))