Documentation
¶
Overview ¶
Package namespace derives PROV-O namespace URIs from git repository metadata.
A namespace is a URI that scopes provenance IDs to a project. For git repos, the canonical HTTPS remote URL is used directly (globally unique, dereferenceable). For non-git directories, a file:// URI is used.
This package has no dependencies on pkg/ptypes or any internal packages, so it can be imported independently by both provenance and pasture.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoRemote = errors.New("namespace: no git remote URL")
ErrNoRemote is returned by FromGitRemote when the remote URL is empty.
Functions ¶
func DefaultNamespace ¶
DefaultNamespace derives a namespace URI from the current git repo's remote URL, falling back to a file:// URI of the working directory.
Derivation order:
- Run "git remote get-url origin" — if successful, normalize to HTTPS URI
- If git fails (not a repo, no origin, git not installed), use file:// URI
- Only returns an error if both strategies fail (e.g., cannot determine cwd)
func FromDirectory ¶
FromDirectory returns a file:// URI for the given directory path. The path is cleaned but not resolved to an absolute path — callers should pass an absolute path for a well-formed URI.
func FromGitRemote ¶
FromGitRemote normalizes a git remote URL to a canonical HTTPS URI. Strips .git suffix, converts SSH/git protocol to HTTPS.
Supported formats:
- https://github.com/user/repo.git -> https://github.com/user/repo
- git@github.com:user/repo.git -> https://github.com/user/repo
- ssh://git@github.com/user/repo.git -> https://github.com/user/repo
- https://github.com/user/repo -> https://github.com/user/repo (no-op)
Returns ErrNoRemote if remoteURL is empty.
Types ¶
This section is empty.