Skip to content

Commit 57dd575

Browse files
Extract filenames from diffs better.
This is a followup to: http://codereview.chromium.org/8059009/ Only add the file once instead of twice (since the diff has --- and +++ lines for each file). Strip whitespace at the end (git diffs don't include a \t so split('\t') isn't enough). Remove leading 'a/' from the path, since git diffs have these. BUG=none TEST=manual Review URL: http://codereview.chromium.org/8050017 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@102934 0039d316-1c4b-4281-b951-d872f2087c98
1 parent 1516995 commit 57dd575

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

trychange.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,11 @@ def GetMungedDiff(path_diff, diff):
478478
for i in range(len(diff)):
479479
if diff[i].startswith('--- ') or diff[i].startswith('+++ '):
480480
new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/')
481-
changed_files.append(('M', new_file.split('\t')[0]))
481+
if diff[i].startswith('--- '):
482+
file_path = new_file.split('\t')[0].strip()
483+
if file_path.startswith('a/'):
484+
file_path = file_path[2:]
485+
changed_files.append(('M', file_path))
482486
diff[i] = diff[i][0:4] + new_file
483487
return (diff, changed_files)
484488

0 commit comments

Comments
 (0)