[scm] Fix list all files when filename has space

Off by one - we should have 4 parts, so we need maxsplit=3.

R=aravindvasudev@google.com, jojwang

Fixed: 1474283
Change-Id: I13b568feb8ee2aa307a2267c43765c1749b77c90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4799773
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
changes/73/4799773/2
Josip Sokcevic 2 years ago committed by LUCI CQ
parent 8060241ee0
commit 2d5c673fdb

@ -385,7 +385,7 @@ class GIT(object):
command = ['-c', 'core.quotePath=false', 'ls-files', '-s', '--', '.'] command = ['-c', 'core.quotePath=false', 'ls-files', '-s', '--', '.']
files = GIT.Capture(command, cwd=cwd).splitlines(False) files = GIT.Capture(command, cwd=cwd).splitlines(False)
# return only files # return only files
return [f.split(maxsplit=4)[-1] for f in files if f.startswith('100')] return [f.split(maxsplit=3)[-1] for f in files if f.startswith('100')]
@staticmethod @staticmethod
def GetPatchName(cwd): def GetPatchName(cwd):

@ -233,8 +233,10 @@ class FakeRepos(FakeReposBase):
'origin': 'git/repo_3@2\n', 'origin': 'git/repo_3@2\n',
}) })
self._commit_git('repo_1', { self._commit_git(
'DEPS': """ 'repo_1',
{
'DEPS': """
vars = { vars = {
'DummyVariable': 'repo', 'DummyVariable': 'repo',
'false_var': False, 'false_var': False,
@ -272,15 +274,16 @@ deps_os = {
'src/repo4': '/repo_4', 'src/repo4': '/repo_4',
}, },
}""" % { }""" % {
'git_base': self.git_base, 'git_base': self.git_base,
# See self.__init__() for the format. Grab's the hash of the first # See self.__init__() for the format. Grab's the hash of the
# commit in repo_2. Only keep the first 7 character because of: # first commit in repo_2. Only keep the first 7 character
# TODO(maruel): http://crosbug.com/3591 We need to strip the hash.. # because of: TODO(maruel): http://crosbug.com/3591 We need to
# duh. # strip the hash.. duh.
'hash3': self.git_hashes['repo_3'][1][0][:7] 'hash3': self.git_hashes['repo_3'][1][0][:7]
}, },
'origin': 'git/repo_1@1\n', 'origin': 'git/repo_1@1\n',
}) 'foo bar': 'some file with a space',
})
self._commit_git('repo_2', { self._commit_git('repo_2', {
'origin': 'git/repo_2@1\n', 'origin': 'git/repo_2@1\n',

@ -170,7 +170,8 @@ class RealGitTest(fake_repos.FakeReposTestBase):
self.assertFalse(scm.GIT.IsAncestor(self.githash('repo_1', 1), 'zebra')) self.assertFalse(scm.GIT.IsAncestor(self.githash('repo_1', 1), 'zebra'))
def testGetAllFiles(self): def testGetAllFiles(self):
self.assertEqual(['DEPS','origin'], scm.GIT.GetAllFiles(self.cwd)) self.assertEqual(['DEPS', 'foo bar', 'origin'],
scm.GIT.GetAllFiles(self.cwd))
def testGetSetConfig(self): def testGetSetConfig(self):
key = 'scm.test-key' key = 'scm.test-key'

Loading…
Cancel
Save