Record a source revision

Install the package, then run this example:

import pystac
from pystac.extensions.vcs import VcsExtension

catalog = pystac.Catalog("source", "Source-controlled catalog")
vcs = VcsExtension.ext(catalog, add_if_missing=True)
vcs.apply(vcs_type="git", branch="main", revision="abc123", tag="v1.0.0")

source = pystac.Link("vcs", "https://example.org/team/repository")
catalog.add_link(source)
VcsExtension.ext(source).apply(vcs_type="git", revision="abc123")

serialized = catalog.to_dict()
assert serialized["vcs:branch"] == "main"
assert VcsExtension.get_schema_uri() in serialized["stac_extensions"]
restored = pystac.Catalog.from_dict(serialized)
assert VcsExtension.ext(restored).revision == "abc123"

Collections use the same top-level fields; Items store VCS metadata in properties. Links and Assets store their own fields and do not inherit their owner's values. Use VcsExtension.ext(target) explicitly; no target.ext.vcs shortcut is registered.

Serialization does not perform validation. See validation boundaries.