From 94c5759e71bac434ef2787a2b85ce1cb1e6efa02 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 11 Apr 2012 11:59:43 +0100 Subject: builder: ensure working directory matches commit When making a copy of the repository to build from, builder copies the .git directory then checks out the ref it wants. However sometimes this doesn't add the files to the working directory, possibly because the files it is missing weren't changed in the difference between what the .git thought HEAD was and what is now checked out. --- morphlib/git.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'morphlib/git.py') diff --git a/morphlib/git.py b/morphlib/git.py index 950fba31..0ee07259 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -252,6 +252,13 @@ def checkout_ref(gitdir, ref, msg=logging.debug): ex = morphlib.execute.Execute(gitdir, msg=msg) ex.runv(['git', 'checkout', ref]) +def reset_workdir(gitdir, msg=logging.debug): + '''Removes any differences between the current commit ''' + '''and the status of the working directory''' + ex = morphlib.execute.Execute(gitdir, msg=msg) + ex.runv(['git', 'clean', '-fxd']) + ex.runv(['git', 'reset', '--hard', 'HEAD']) + def set_submodule_url(gitdir, name, url, msg=logging.debug): '''Changes the URL of a submodule to point to a specific location.''' ex = morphlib.execute.Execute(gitdir, msg=msg) -- cgit v1.2.1