diff options
author | Phil Dawson <phil.dawson@codethink.co.uk> | 2019-03-06 10:23:55 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-07 15:02:58 +0000 |
commit | a28f481eff6746fcad964444f8499eb2f5918a3d (patch) | |
tree | 422d9a3b1cfa62bb77b6052d2b01cd47110f05e5 | |
parent | dd36cfb798166da050f52aa563ea726241b8a299 (diff) | |
download | buildstream-a28f481eff6746fcad964444f8499eb2f5918a3d.tar.gz |
_gitsourcebase.py: Make mirror class used by derived plugins overridable
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.py | 11 |
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 |