From ade83db15465ee613924a3ff78ba4b2cd03a9b3c Mon Sep 17 00:00:00 2001 From: "lliabraa@chromium.org" Date: Thu, 27 Sep 2012 14:06:49 +0000 Subject: [PATCH] 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 --- gclient_scm.py | 1 + tests/gclient_smoketest.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index d34a6506b..12e1bf0aa 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -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): diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index b978ad6aa..481492cf7 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -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)