This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/sboms
in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git

commit 762a16deee22586f352f51e0f18cb1ac8c4ba39b
Author: Tristan van Berkom <[email protected]>
AuthorDate: Sun Mar 30 18:41:52 2025 +0900

    sources/cargo.py: Implement collect_source_info()
---
 src/buildstream_plugins/sources/cargo.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/buildstream_plugins/sources/cargo.py 
b/src/buildstream_plugins/sources/cargo.py
index ff49cd9..dbddfe3 100644
--- a/src/buildstream_plugins/sources/cargo.py
+++ b/src/buildstream_plugins/sources/cargo.py
@@ -74,7 +74,7 @@ try:
 except ImportError:
     import tomli as tomllib  # type: ignore
 
-from buildstream import Source, SourceFetcher, SourceError
+from buildstream import Source, SourceFetcher, SourceError, SourceInfo, 
SourceInfoMedium, SourceVersionType
 from buildstream import utils
 
 from ._utils import download_file
@@ -332,6 +332,18 @@ class Crate(SourceFetcher):
     def _get_mirror_file(self, sha=None):
         return os.path.join(self._get_mirror_dir(), sha or self.sha)
 
+    # _get_source_info()
+    #
+    # Gets the SourceInfo object for this crate
+    #
+    # Returns: The SourceInfo object
+    #
+    def _get_source_info(self):
+        url, _ = self._get_url()
+        return SourceInfo(
+            url, SourceInfoMedium.REMOTE_FILE, SourceVersionType.SHA256, 
self.sha, version_guess=self.version
+        )
+
 
 class CargoSource(Source):
     BST_MIN_VERSION = "2.0"
@@ -451,6 +463,9 @@ class CargoSource(Source):
     def get_source_fetchers(self):
         return self.crates
 
+    def collect_source_info(self):
+        return [crate._get_source_info() for crate in self.crates]
+
     ########################################################
     #                   Private helpers                    #
     ########################################################

Reply via email to