Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsLocalPath ¶
IsLocalPath reports whether ref looks like a local filesystem path or file URI rather than a remote URL. Use this to decide between Clone and OpenLocal. Anything that is not a recognized remote URL scheme (https, http, ssh, git, git@) is treated as local, so paths like ".", "..", "../../configs", or absolute paths all work without explicit enumeration.
func ParseURLSubdir ¶
ParseURLSubdir splits a repository URL on the "//" subdirectory separator. e.g. "https://github.com/user/repo//configs" → ("https://github.com/user/repo", "configs", nil) Works correctly with https://, ssh://, git://, and git@ URLs. Returns an error if the subdirectory contains ".." components or is absolute.
Types ¶
type CloneOptions ¶
type CloneOptions struct {
URL string
// ReferenceName is the branch or tag to clone (e.g. "refs/heads/main").
// If empty, the remote's default branch is used.
// Cannot be combined with CommitHash.
ReferenceName string
// CommitHash, if set, checks out this exact commit after cloning (full 40-char SHA only).
// Requires a full clone — Depth is set to 0 (unlimited) automatically.
// Cannot be combined with ReferenceName.
CommitHash string
// Subdirectory, if set, is prepended to all paths in GetFiles.
// Must not contain ".." components; use ParseURLSubdir to extract from a URL.
Subdirectory string
// SSH auth (used for git@ or ssh:// URLs).
SSHKeyPath string // path to private key file; if empty, uses SSH agent
SSHKeyPassword string // passphrase for encrypted SSH key
// HTTP auth (used for https:// URLs only — credentials are never sent over http://).
Token string // bearer token; takes precedence over Username/Password
Username string
Password string
}
CloneOptions configures how a repository is cloned and authenticated.
func (CloneOptions) String ¶
func (o CloneOptions) String() string
String returns a representation of CloneOptions with sensitive fields redacted.
type FileContent ¶
FileContent holds a file's path and raw content from a cloned repository.
type Repository ¶
type Repository interface {
GetFiles(paths []string) ([]FileContent, error)
}
Repository provides read access to a cloned git repository.
func Clone ¶
func Clone(opts CloneOptions, progress io.Writer) (Repository, error)
Clone clones a repository into memory and returns a Repository for reading files. progress may be nil.
func OpenLocal ¶
func OpenLocal(repoPath, subdir string) (Repository, error)
OpenLocal opens a local git repository for reading. path may be an absolute path, a relative path (resolved from CWD), or a file:// URI. subdir, if non-empty, is prepended to all paths in GetFiles.