Index: tools/git/move_source_file.py |
diff --git a/tools/git/move_source_file.py b/tools/git/move_source_file.py |
index f1dde3b3e11ff39023dba95e6b9b6ec50b9fd889..6d3c8e77f33922ecdbc5347d22bce3b74487a52b 100755 |
--- a/tools/git/move_source_file.py |
+++ b/tools/git/move_source_file.py |
@@ -8,8 +8,7 @@ to them, and re-ordering headers as needed. If multiple source files are |
specified, the destination must be a directory. Updates include guards in |
moved header files. Assumes Chromium coding style. |
-Attempts to update paths used in .gyp(i) files, but does not reorder |
-or restructure .gyp(i) files in any way. |
+Attempts to update and reorder paths used in .gyp(i) files. |
Updates full-path references to files in // comments in source files. |
@@ -213,11 +212,18 @@ def UpdateIncludeGuard(old_path, new_path): |
f.write(new_contents) |
def main(): |
- if not os.path.isdir('.git'): |
- print 'Fatal: You must run from the root of a git checkout.' |
+ # We use "git rev-parse" to check if the script is run from a git checkout. It |
+ # returns 0 even when run in the .git directory. We don't want people running |
+ # this in the .git directory. |
+ if (not os.system('git rev-parse') == 0 or |
scottmg
2016/01/21 19:57:20
os.system() != 0 seems more natural
dgrogan
2016/01/21 20:05:49
Done.
|
+ os.path.basename(os.getcwd()) == '.git'): |
+ print 'Fatal: You must run in a git checkout.' |
return 1 |
- in_blink = os.getcwd().endswith("third_party/WebKit") |
+ cwd = os.getcwd() |
+ parent = os.path.dirname(cwd) |
+ in_blink = (os.path.basename(parent) == 'third_party' and |
scottmg
2016/01/21 19:57:20
I might make this a --blink option with a default
dgrogan
2016/01/21 20:05:49
You're thinking of the move from third_party/WebKi
scottmg
2016/01/21 20:14:39
Yeah, or running from src, but moving a file in th
dgrogan
2016/01/21 20:18:30
Sure doesn't :)
|
+ os.path.basename(cwd) == 'WebKit') |
parser = optparse.OptionParser(usage='%prog FROM_PATH... TO_PATH') |
parser.add_option('--already_moved', action='store_true', |