-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix chromium tools/git/move_source_file.py (#13579)
* Fix chromium tools/git/move_source_file.py * Add npm run mass-rename * Add a comment * Review fixes * mass-rename => mass_rename * More review fixes
- Loading branch information
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
diff --git a/tools/git/move_source_file.py b/tools/git/move_source_file.py | ||
index ab57ae721179f77bb92b808e65dfe1ced8cf605f..ef3fb8f06b312609cf86e0c088e7c4804c9eef8e 100755 | ||
--- a/tools/git/move_source_file.py | ||
+++ b/tools/git/move_source_file.py | ||
@@ -91,6 +91,7 @@ def UpdatePostMove(from_path, to_path): | ||
to update references in .gyp(i) files using a heuristic. | ||
""" | ||
# Include paths always use forward slashes. | ||
+ from move_source_fille_utils import to_src_relative_path; from_path, to_path = to_src_relative_path(from_path, to_path) | ||
from_path = from_path.replace('\\', '/') | ||
to_path = to_path.replace('\\', '/') | ||
extension = os.path.splitext(from_path)[1] | ||
@@ -115,6 +116,7 @@ def UpdatePostMove(from_path, to_path): | ||
mffr.MultiFileFindReplace( | ||
r'(//.*)%s' % re.escape(from_path), | ||
r'\1%s' % to_path, | ||
+ ['*.gni', '*.gn'] + # Brave uses full paths (start with //) to add files | ||
['*.cc', '*.h', '*.m', '*.mm', '*.cpp']) | ||
|
||
# Update references in GYP and BUILD.gn files. | ||
@@ -150,6 +152,7 @@ def UpdatePostMove(from_path, to_path): | ||
return (parts[0], '') | ||
|
||
visiting_directory = '' | ||
+ from move_source_fille_utils import to_cwd_relative_path; from_path, to_path = to_cwd_relative_path(from_path, to_path) | ||
from_rest = from_path | ||
to_rest = to_path | ||
while True: | ||
@@ -186,6 +189,7 @@ def UpdateIncludeGuard(old_path, new_path): | ||
old_guard = MakeIncludeGuardName(old_path) | ||
new_guard = MakeIncludeGuardName(new_path) | ||
|
||
+ from move_source_fille_utils import to_cwd_relative_path; [new_path] = to_cwd_relative_path(new_path) | ||
with open(new_path) as f: | ||
contents = f.read() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2022 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
"""This utils is used in chromium tools/git/move_source_file.py.""" | ||
|
||
import os | ||
|
||
BRAVE_DIR_NAME = 'brave' | ||
|
||
def _is_in_brave_dir(): | ||
return BRAVE_DIR_NAME == os.path.basename(os.getcwd()) | ||
|
||
|
||
def to_src_relative_path(*args): | ||
if _is_in_brave_dir(): | ||
return tuple(os.path.join(BRAVE_DIR_NAME, d) for d in args) | ||
return args | ||
|
||
|
||
def to_cwd_relative_path(*args): | ||
if _is_in_brave_dir(): | ||
return tuple(os.path.relpath(d, BRAVE_DIR_NAME) for d in args) | ||
return args |