diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-11 11:59:43 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-11 13:10:27 +0100 |
commit | 94c5759e71bac434ef2787a2b85ce1cb1e6efa02 (patch) | |
tree | 71c912f226aa41ddee146605a5cc5ce958e9bec6 /morphlib | |
parent | 38132bcc37534d9d7727a7e93f2113a6b4e3acd5 (diff) | |
download | morph-94c5759e71bac434ef2787a2b85ce1cb1e6efa02.tar.gz |
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.
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/builder.py | 1 | ||||
-rw-r--r-- | morphlib/git.py | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index ed21f623..4bbf4464 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -115,6 +115,7 @@ class Factory(object): os.mkdir(destdir) morphlib.git.copy_repository(treeish, destdir, msg) morphlib.git.checkout_ref(destdir, treeish.ref, msg) + morphlib.git.reset_workdir(destdir, msg) return [(sub.treeish, os.path.join(destdir, sub.path)) for sub in treeish.submodules] 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) |