Correct Git show's path format on Windows
_CalculateAddedDeps calls into depot tools' scm.py GetOldContents to
compare previous and current versions of the DEPS file. GetOldContents
attempts to 'git show <sha>:<path>'. The problem on Windows is that path
uses '\' but git show seems to want a posix path. Git show therefore
doesn't find the file and returns an empty output, leading presubmit to
think all the deps are new.
Bug:725933
Change-Id: Ifbbfbcba4be466d9be623826818fd191bd2ca525
Reviewed-on: https://chromium-review.googlesource.com/514142
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
diff --git a/scm.py b/scm.py
index 88016dc..8708c19 100644
--- a/scm.py
+++ b/scm.py
@@ -8,6 +8,7 @@
import glob
import logging
import os
+import platform
import re
import sys
import tempfile
@@ -258,6 +259,9 @@
def GetOldContents(cwd, filename, branch=None):
if not branch:
branch = GIT.GetUpstreamBranch(cwd)
+ if platform.system() == 'Windows':
+ # git show <sha>:<path> wants a posix path.
+ filename = filename.replace('\\', '/')
command = ['show', '%s:%s' % (branch, filename)]
try:
return GIT.Capture(command, cwd=cwd, strip_out=False)