namespace

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 6 Imported by: 0

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

View Source
var ErrNoRemote = errors.New("namespace: no git remote URL")

ErrNoRemote is returned by FromGitRemote when the remote URL is empty.

Functions

func DefaultNamespace

func DefaultNamespace() (string, error)

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:

  1. Run "git remote get-url origin" — if successful, normalize to HTTPS URI
  2. If git fails (not a repo, no origin, git not installed), use file:// URI
  3. Only returns an error if both strategies fail (e.g., cannot determine cwd)

func FromDirectory

func FromDirectory(dir string) string

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

func FromGitRemote(remoteURL string) (string, error)

FromGitRemote normalizes a git remote URL to a canonical HTTPS URI. Strips .git suffix, converts SSH/git protocol to HTTPS.

Supported formats:

Returns ErrNoRemote if remoteURL is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL