summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dawson <phil.dawson@codethink.co.uk>2019-03-06 10:23:55 +0000
committerPhil Dawson <phil.dawson@codethink.co.uk>2019-03-07 10:01:20 +0000
commit2b3f2462def58ec5bb080a15a234a3b6ae564e80 (patch)
tree961f7c87ade75f4b2a343dffca90ec4645303b10
parent6524f1c374c5dd6ac06dcc84608cf195e20d3d52 (diff)
downloadbuildstream-chandan/base-git-mirror.tar.gz
_gitsourcebase.py: Make mirror class used by derived plugins overridablechandan/base-git-mirror
We want it to be possible for plugin authors writing git type plugins derrived from _GitSourceBase to be able to make use of custom _GitMirror classes. Add a MirrorClass class variable to _GitSourceBase which can be overriden by derriving classes. This allows plugin authors to specify the use of custom/derrived _GitMirror class.
-rw-r--r--buildstream/_gitsourcebase.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/buildstream/_gitsourcebase.py b/buildstream/_gitsourcebase.py
index ade5f3c0a..8c640da8a 100644
--- a/buildstream/_gitsourcebase.py
+++ b/buildstream/_gitsourcebase.py
@@ -370,6 +370,11 @@ class _GitMirror(SourceFetcher):
class _GitSourceBase(Source):
# pylint: disable=attribute-defined-outside-init
+ # The GitMirror class which this plugin uses. This may be
+ # overridden in derived plugins as long as the replacement class
+ # follows the same interface used by the _GitMirror class
+ BST_MIRROR_CLASS = _GitMirror
+
def configure(self, node):
ref = self.node_get_member(node, str, 'ref', None)
@@ -386,7 +391,7 @@ class _GitSourceBase(Source):
self.track_tags = self.node_get_member(node, bool, 'track-tags', False)
self.original_url = self.node_get_member(node, str, 'url')
- self.mirror = _GitMirror(self, '', self.original_url, ref, tags=tags, primary=True)
+ self.mirror = self.BST_MIRROR_CLASS(self, '', self.original_url, ref, tags=tags, primary=True)
self.tracking = self.node_get_member(node, str, 'track', None)
self.ref_format = self.node_get_member(node, str, 'ref-format', 'sha1')
@@ -629,7 +634,7 @@ class _GitSourceBase(Source):
return True
- # Refreshes the _GitMirror objects for submodules
+ # Refreshes the BST_MIRROR_CLASS objects for submodules
#
# Assumes that we have our mirror and we have the ref which we point to
#
@@ -651,7 +656,7 @@ class _GitSourceBase(Source):
ref = self.mirror.submodule_ref(path)
if ref is not None:
- mirror = _GitMirror(self, path, url, ref)
+ mirror = self.BST_MIRROR_CLASS(self, path, url, ref)
submodules.append(mirror)
self.submodules = submodules