From fc1c6f4c1fac4de7647da83425f4398dde6e77ca Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Manzagol Date: Tue, 30 May 2017 12:29:58 -0400 Subject: [PATCH] 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 :'. 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 Reviewed-by: Nodir Turakulov --- scm.py | 4 ++++ tests/scm_unittest.py | 1 + 2 files changed, 5 insertions(+) diff --git a/scm.py b/scm.py index 88016dccd..8708c19b0 100644 --- a/scm.py +++ b/scm.py @@ -8,6 +8,7 @@ import cStringIO import glob import logging import os +import platform import re import sys import tempfile @@ -258,6 +259,9 @@ class GIT(object): def GetOldContents(cwd, filename, branch=None): if not branch: branch = GIT.GetUpstreamBranch(cwd) + if platform.system() == 'Windows': + # git show : wants a posix path. + filename = filename.replace('\\', '/') command = ['show', '%s:%s' % (branch, filename)] try: return GIT.Capture(command, cwd=cwd, strip_out=False) diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py index 400ca18c1..8ee3d811a 100755 --- a/tests/scm_unittest.py +++ b/tests/scm_unittest.py @@ -58,6 +58,7 @@ class RootTestCase(BaseSCMTestCase): 'logging', 'only_int', 'os', + 'platform', 're', 'subprocess2', 'sys',