Repo: gitano@roadtrain.codethink.co.uk:baserock/morph.git
Ref: baserock/bugfix/S3595-morph-updates-gits-too-often
Sha1: cfcfb85c14a4021b965fe718db8405acad16c490
Morph will currently update the git repositories for chunk builds,
even if it already has the commit needed locally.
This patch fixes that.
Richard Maw (1):
BuildCommand: don't always update git repositories
morphlib/app.py | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
--
1.7.5.4
Show replies by date
If it already has the sha1 needed, then don't run update-gits again.
---
morphlib/app.py | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/morphlib/app.py b/morphlib/app.py
index ebe9be1..c6ff2f1 100755
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -238,7 +238,7 @@ class BuildCommand(object):
repo_name = artifact.source.repo_name
if self.app.settings['no-git-update']:
self.app.status(msg='Not updating existing git repository '
- '%(repo_name)s'
+ '%(repo_name)s '
'because of no-git-update being set',
chatty=True,
repo_name=repo_name)
@@ -246,10 +246,20 @@ class BuildCommand(object):
return
if self.lrc.has_repo(repo_name):
- self.app.status(msg='Updating %(repo_name)s',
- repo_name=repo_name)
artifact.source.repo = self.lrc.get_repo(repo_name)
- artifact.source.repo.update()
+ try:
+ sha1 = artifact.source.sha1
+ artifact.source.repo.resolve_ref(sha1)
+ self.app.status(msg='Not updating git repository '
+ '%(repo_name)s because it '
+ 'already contains sha1 %(sha1)s',
+ chatty=True, repo_name=repo_name,
+ sha1=sha1)
+ return
+ except morphlib.cachedrepo.InvalidReferenceError:
+ self.app.status(msg='Updating %(repo_name)s',
+ repo_name=repo_name)
+ artifact.source.repo.update()
else:
self.app.status(msg='Cloning %(repo_name)s',
repo_name=repo_name)
--
1.7.5.4