diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-07 15:48:39 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-03-07 15:48:39 +0000 |
commit | 4359b50a851be0fe0202f06cf230ced921b2deff (patch) | |
tree | 422d9a3b1cfa62bb77b6052d2b01cd47110f05e5 | |
parent | 5370740fc1eef6daf144831b148f13f883ebcd42 (diff) | |
parent | a28f481eff6746fcad964444f8499eb2f5918a3d (diff) | |
download | buildstream-4359b50a851be0fe0202f06cf230ced921b2deff.tar.gz |
Merge branch 'chandan/base-git-mirror' into 'master'
Expose _GitMirror as part of plugin author facing API
See merge request BuildStream/buildstream!1022
-rw-r--r-- | buildstream/__init__.py | 2 | ||||
-rw-r--r-- | buildstream/_gitsourcebase.py | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/buildstream/__init__.py b/buildstream/__init__.py index f9a662df1..62890a62f 100644 --- a/buildstream/__init__.py +++ b/buildstream/__init__.py @@ -38,4 +38,4 @@ if "_BST_COMPLETION" not in os.environ: # XXX We are exposing a private member here as we expect it to move to a # separate package soon. See the following discussion for more details: # https://gitlab.com/BuildStream/buildstream/issues/739#note_124819869 - from ._gitsourcebase import _GitSourceBase + from ._gitsourcebase import _GitSourceBase, _GitMirror diff --git a/buildstream/_gitsourcebase.py b/buildstream/_gitsourcebase.py index c0913409c..8c640da8a 100644 --- a/buildstream/_gitsourcebase.py +++ b/buildstream/_gitsourcebase.py @@ -42,11 +42,11 @@ WARN_UNLISTED_SUBMODULE = "unlisted-submodule" WARN_INVALID_SUBMODULE = "invalid-submodule" -# Because of handling of submodules, we maintain a GitMirror +# Because of handling of submodules, we maintain a _GitMirror # for the primary git source and also for each submodule it # might have at a given time # -class GitMirror(SourceFetcher): +class _GitMirror(SourceFetcher): def __init__(self, source, path, url, ref, *, primary=False, tags=[]): @@ -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 |