From 933d8fe56e82e971f5bef16d523ceaedf8b27f4b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 2 Aug 2013 12:50:38 +0000 Subject: Add LocalRepoCache.get_updated_repo method This is a helper to avoid having the same code in other places. Have it in the one place it belongs. --- morphlib/localrepocache.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'morphlib/localrepocache.py') diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py index 465e9f03..aa45cd3d 100644 --- a/morphlib/localrepocache.py +++ b/morphlib/localrepocache.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 Codethink Limited +# Copyright (C) 2012-2013 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -285,3 +285,15 @@ class LocalRepoCache(object): self._cached_repo_objects[reponame] = repo return repo raise NotCached(reponame) + + def get_updated_repo(self, reponame): # pragma: no cover + '''Return object representing cached repository, which is updated.''' + + self._app.status(msg='Updating git repository %s in cache' % reponame) + if not self._app.settings['no-git-update']: + cached_repo = self.cache_repo(reponame) + cached_repo.update() + else: + cached_repo = self.get_repo(reponame) + return cached_repo + -- cgit v1.2.1