Skip to content

Commit bbc05ba

Browse files
committed
source.py: Allow source provenance info to be overridden
This allows multi-source source plugins to provide this information per source rather than as a singular top level. This is done by adding a `provenance_node` parameter to `create_source_info()` that when specified overrides the use of the source's top level source provenance info. Co-authored-by: Jürg Billeter <[email protected]>
1 parent 86a950a commit bbc05ba

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/buildstream/source.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,7 @@ def create_source_info(
13671367
version: str,
13681368
*,
13691369
version_guess: Optional[str] = None,
1370+
provenance_node: Optional[MappingNode] = None,
13701371
extra_data: Optional[Dict[str, str]] = None,
13711372
) -> SourceInfo:
13721373
"""Create a :class:`.SourceInfo` object
@@ -1386,15 +1387,23 @@ def create_source_info(
13861387
choice depicting the type of version.
13871388
version: A string which represents a unique version of this source input
13881389
version_guess: An optional string representing the guessed human readable version
1390+
provenance_node: The optional YAML node with source provenance attributes,
1391+
defaults to the provenance specified at the top level of the source.
13891392
extra_data: Additional plugin defined key/values
13901393
13911394
*Since: 2.5*
13921395
"""
13931396
homepage = None
13941397
issue_tracker = None
1395-
if self.__provenance is not None:
1396-
homepage = self.__provenance.homepage
1397-
issue_tracker = self.__provenance.issue_tracker
1398+
1399+
if provenance_node is not None:
1400+
provenance: Optional[_SourceProvenance] = _SourceProvenance.new_from_node(provenance_node)
1401+
else:
1402+
provenance = self.__provenance
1403+
1404+
if provenance is not None:
1405+
homepage = provenance.homepage
1406+
issue_tracker = provenance.issue_tracker
13981407

13991408
return SourceInfo(
14001409
self.get_kind(),

0 commit comments

Comments
 (0)