summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben@demerara.io>2021-10-13 18:50:09 +0100
committerBen Brown <ben@demerara.io>2021-10-13 18:57:48 +0100
commit4f04d3134af3d3dfeb3bab7f5a4745a9c2160064 (patch)
treed6ae8b097c50ef0eb59baa995eb73194eaf7148b
parent6481be75c568c64c6448915b3ff1fa088a056e5a (diff)
downloadlorry-controller-4f04d3134af3d3dfeb3bab7f5a4745a9c2160064.tar.gz
readconf: unify clone and update into single fetch method
-rw-r--r--lorrycontroller/readconf.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index 8f95035..02f11a2 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -99,23 +99,18 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
def get_confgit(self):
if self.app_settings['debug-real-confgit']:
confdir = self.app_settings['configuration-directory']
- if not os.path.exists(confdir):
- self.git_clone_confgit(confdir)
- else:
- self.update_confgit(confdir)
+ self.fetch_confgit(confdir)
- def git_clone_confgit(self, confdir):
+ def fetch_confgit(self, confdir):
url = self.app_settings['confgit-url']
- branch = self.app_settings['confgit-branch']
- logging.info('Cloning %s to %s', url, confdir)
- cliapp.runcmd(['git', 'clone', '-b', branch, url, confdir])
+ origin_branch = 'origin/' + self.app_settings['confgit-branch']
+ logging.info('Fetching CONFGIT in %s', confdir)
- def update_confgit(self, confdir):
- logging.info('Updating CONFGIT in %s', confdir)
+ if not os.path.exists(confdir):
+ cliapp.runcmd(['git', 'init', confdir])
# First ensure that the confgit repo is using the correct
# upstream source.
- url = self.app_settings['confgit-url']
cliapp.runcmd(['git', 'remote', 'set-url', 'origin', url], cwd=confdir)
# The following sequence makes the working tree mirror
@@ -136,7 +131,6 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
# 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.
- origin_branch = 'origin/' + self.app_settings['confgit-branch']
cliapp.runcmd(
['git', 'reset', '--hard', origin_branch], cwd=confdir)