Documentation
¶
Overview ¶
Package git provides utilities for interacting with git repositories.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidRemoteURL = errors.New("invalid remote URL")
ErrInvalidRemoteURL is returned when the remote URL cannot be parsed.
Functions ¶
This section is empty.
Types ¶
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.