repoid

package
v0.37.12 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package repoid resolves stable Studio repository entity IDs.

Feature: cli/studio/index (REQ: fact-shape)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalID

func LocalID(repoPath string) string

LocalID returns an order-independent ID for a local-only repository. The readable basename is paired with a short hash of the normalized absolute path, so same-basename repositories remain distinct without `-2` aliases.

func ParseRemote

func ParseRemote(raw string) (string, bool)

ParseRemote normalizes a supported git remote URL to `host/path`. URL-style HTTPS, HTTP, SSH and git remotes and SCP-style SSH remotes are supported. Transport, credentials, a trailing slash, and a trailing `.git` do not form part of repository identity. Local/file remotes and unsafe paths are rejected.

Types

type OriginURLFunc

type OriginURLFunc func(dir string) (string, error)

OriginURLFunc resolves the origin remote URL for a local repository path. A missing origin, a non-repository directory, or any other git failure is represented by a non-nil error and makes the resolver use the local-only ID.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver mints stable repository IDs and detects two different paths that resolve to the same identity. It is intentionally stateful for one workspace run so an identity collision cannot silently merge two ingestion sources.

func NewResolver

func NewResolver() *Resolver

NewResolver returns a resolver backed by `git remote get-url origin`.

func NewResolverWithOriginURL

func NewResolverWithOriginURL(originURL OriginURLFunc) *Resolver

NewResolverWithOriginURL returns a resolver with an injectable origin lookup.

func (*Resolver) ID

func (r *Resolver) ID(repoPath string) (string, error)

ID returns a stable repository entity ID. A supported origin remote becomes its normalized forge coordinate (`host/org/name`). A repository without a supported origin uses a deterministic local-only ID derived from its absolute path. If another path already claimed the same ID, ID returns that ID alongside an error instead of assigning an input-order suffix.

Jump to

Keyboard shortcuts

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