diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-02 12:50:38 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-06 16:28:16 +0100 |
commit | 933d8fe56e82e971f5bef16d523ceaedf8b27f4b (patch) | |
tree | 6a94537f5bfe25b0b6249eda9593435535d9522d /morphlib/localrepocache.py | |
parent | ddb490714f43119441aabdd492d09520c73e3448 (diff) | |
download | morph-933d8fe56e82e971f5bef16d523ceaedf8b27f4b.tar.gz |
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.
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r-- | morphlib/localrepocache.py | 14 |
1 files changed, 13 insertions, 1 deletions
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 + |