summaryrefslogtreecommitdiff
path: root/lorrycontroller/readconf.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/readconf.py')
-rw-r--r--lorrycontroller/readconf.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index d060067..4aa3161 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -101,7 +101,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
if not os.path.exists(confdir):
self.git_clone_confgit(confdir)
else:
- self.git_pull_confgit(confdir)
+ self.update_confgit(confdir)
def git_clone_confgit(self, confdir):
url = self.app_settings['confgit-url']
@@ -109,9 +109,29 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
logging.info('Cloning %s to %s', url, confdir)
cliapp.runcmd(['git', 'clone', '-b', branch, url, confdir])
- def git_pull_confgit(self, confdir):
+ def update_confgit(self, confdir):
logging.info('Updating CONFGIT in %s', confdir)
- cliapp.runcmd(['git', 'pull'], cwd=confdir)
+
+ # The following sequence makes the working tree mirror
+ # current upstream git repository as closely as possible.
+
+ # Get rid of any local changes. No human is meant to edit
+ # anything locally, but there may be remnants of failed
+ # runs.
+ cliapp.runcmd(['git', 'reset', '--hard'], cwd=confdir)
+
+ # Get rid of any files not known by git. This might be,
+ # say, core dumps.
+ cliapp.runcmd(['git', 'clean', '-fdx'], cwd=confdir)
+
+ # Fetch updates to remote branches.
+ cliapp.runcmd(['git', 'remote', 'update', 'origin'], cwd=confdir)
+
+ # Now move the current HEAD to wherever the remote master
+ # branch is, no questions asked. This doesn't do merging
+ # or any of the other things we don't want in this situation.
+ cliapp.runcmd(
+ ['git', 'reset', '--hard', 'origin/master'], cwd=confdir)
@property
def config_file_name(self):