summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben@demerara.io>2021-10-13 18:54:24 +0100
committerBen Brown <ben@demerara.io>2021-10-13 18:58:54 +0100
commitc9ed154719282e96526a869db40c6958703094fd (patch)
treed8c08786a8384db97bdbde69c19c796b60755d4a
parent5475de95a694a007a1b7bfb23074401ebcb9cacd (diff)
downloadlorry-controller-c9ed154719282e96526a869db40c6958703094fd.tar.gz
Fetch without the need to touch remotes
-rw-r--r--lorrycontroller/readconf.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index 38b9a7f..18dda41 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -103,31 +103,26 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
def fetch_confgit(self, confdir):
url = self.app_settings['confgit-url']
- origin_branch = 'origin/' + self.app_settings['confgit-branch']
+ branch = self.app_settings['confgit-branch']
logging.info('Fetching 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.
- cliapp.runcmd(['git', 'remote', 'set-url', 'origin', url], cwd=confdir)
-
# The following sequence makes the working tree mirror
# current upstream git repository as closely as possible.
+ # Fetch updates to remote branch.
+ cliapp.runcmd(['git', 'fetch', '--prune', url, branch], 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_branch], cwd=confdir)
+ # Now move the current HEAD to whatever we just fetched, 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', 'FETCH_HEAD'], cwd=confdir)
@property
def config_file_name(self):