Add 'git clean -f -d' to 'gclient revert' when in a git repo.

The try slaves run 'git revert' to clean up from the previous run. This only runs 'git reset --hard', which does not remove any untracked files, so if a CL adds a new file it will still be present after 'gclient revert'. Adding git clean -f -d removes untracked files (-f) and directories (-d).

Review URL: https://chromiumcodereview.appspot.com/10986032

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@159020 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
lliabraa@chromium.org 13 years ago
parent 5a30792458
commit ade83db154

@ -540,6 +540,7 @@ class GitWrapper(SCMWrapper):
files = self._Capture(['diff', deps_revision, '--name-only']).split()
self._Run(['reset', '--hard', deps_revision], options)
self._Run(['clean', '-f', '-d'], options)
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
def revinfo(self, options, args, file_list):

@ -940,18 +940,19 @@ class GClientSmokeGIT(GClientSmokeBase):
self.assertEquals(3, len(out))
# Revert implies --force implies running hooks without looking at pattern
# matching.
results = self.gclient(['revert', '--deps', 'mac', '--jobs', '1'])
out = results[0].splitlines(False)
# TODO(maruel): http://crosbug.com/3583 It just runs the hooks right now.
self.assertEquals(13, len(out))
self.checkString('', results[1])
self.assertEquals(0, results[2])
# matching. For each expected path, 'git reset' and 'git clean' are run, so
# there should be two results for each. The last two results should reflect
# writing git_hooked1 and git_hooked2.
expected4 = ('running', self.root_dir)
out = self.parseGclient(['revert', '--deps', 'mac', '--jobs', '1'],
[expected1, expected1,
expected2, expected2,
expected3, expected3,
expected4, expected4])
self.assertEquals(8, len(out))
tree = self.mangle_git_tree(('repo_1@2', 'src'),
('repo_2@1', 'src/repo2'),
('repo_3@2', 'src/repo2/repo_renamed'))
# TODO(maruel): http://crosbug.com/3583 This file should have been removed.
tree[join('src', 'repo2', 'hi')] = 'Hey!'
tree['src/git_hooked1'] = 'git_hooked1'
tree['src/git_hooked2'] = 'git_hooked2'
self.assertTree(tree)

Loading…
Cancel
Save