INNER CODE UNIT · Python
submodules
toyota-connected/ivi-homescreen · scripts/gen_sbom.py:57
def submodules(root):
"""Each submodule as (path, url), in .gitmodules order."""
config = configparser.ConfigParser()
config.read(root / ".gitmodules")
found = []
for section in config.sections():
if not section.startswith("submodule "):
continue
found.append((config[section]["path"], config[section]["url"]))
return found
def pinned_commit(root, path):
"""The commit this repository pins, without needing the submodule checked out."""
line = run(["git", "ls-tree", "HEAD", path], cwd=root)
if not line:
raise SystemExit(f"gen_sbom: {path} is in .gitmodules but not in the tree")
return line.split()[2]