git

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package git provides utilities for interacting with git repositories.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRemoteURL = errors.New("invalid remote URL")

ErrInvalidRemoteURL is returned when the remote URL cannot be parsed.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	URL    string
	SHA    string
	Branch string
}

Metadata contains repository information.

type RemoteInfo

type RemoteInfo struct {
	Host        string // e.g., "gitlab.com"
	ProjectPath string // e.g., "gitlab-org/editor-extensions/gitlab-lsp"
}

RemoteInfo contains parsed information from a git remote URL.

func ParseRemoteURL

func ParseRemoteURL(remoteURL string) (*RemoteInfo, error)

ParseRemoteURL parses a git remote URL and extracts the host and project path. Supports the following formats:

  • SSH: git@gitlab.com:user/repo.git
  • SSH explicit: ssh://git@gitlab.com/user/repo.git
  • HTTPS: https://gitlab.com/user/repo.git
  • git://: git://gitlab.com/user/repo.git

The .git suffix is stripped from the project path if present.

type Repository

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

Repository provides git operations for a repository.

func NewRepository

func NewRepository(ctx context.Context, dirPath string) (*Repository, error)

NewRepository creates a Repository for the given path. It finds the repository root from the given directory. Returns an error if the path is not inside a git repository.

func (*Repository) GetMetadata

func (r *Repository) GetMetadata(ctx context.Context) Metadata

GetMetadata extracts metadata from the repository. Individual fields may be empty if they cannot be determined.

func (*Repository) RootPath

func (r *Repository) RootPath() string

RootPath returns the repository root path.

Jump to

Keyboard shortcuts

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