vcs

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package vcs provides version control system abstractions.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidType = errors.New("invalid type")

ErrInvalidType is returned when a type assertion fails for vcs types.

Functions

func SetDefaultOpener

func SetDefaultOpener(opener Opener)

SetDefaultOpener sets the default git opener (useful for testing).

Types

type BlameLine

type BlameLine struct {
	Author     string
	AuthorName string
	Text       string
}

BlameLine represents a single line in a blame result.

type BlameResult

type BlameResult struct {
	Lines []BlameLine
}

BlameResult contains blame information for a file.

type Change

type Change interface {
	// From returns the source file name (empty for new files).
	FromName() string
	// To returns the destination file name (empty for deleted files).
	ToName() string
	// Patch computes the patch for this change.
	Patch() (Patch, error)
}

Change represents a single file change.

type Changes

type Changes []Change

Changes represents a collection of file changes between trees.

type Chunk

type Chunk interface {
	Type() ChunkType
	Content() string
}

Chunk represents a chunk of changes within a file patch.

type ChunkType

type ChunkType int

ChunkType represents the type of change in a chunk.

const (
	ChunkEqual ChunkType = iota
	ChunkAdd
	ChunkDelete
)

type Commit

type Commit interface {
	// Hash returns the commit hash.
	Hash() plumbing.Hash
	// NumParents returns the number of parent commits.
	NumParents() int
	// Parent returns the nth parent commit.
	Parent(n int) (Commit, error)
	// Tree returns the tree object for this commit.
	Tree() (Tree, error)
	// Stats returns file stats for this commit.
	Stats() (object.FileStats, error)
	// Author returns commit author information.
	Author() object.Signature
}

Commit represents a git commit.

type CommitIterator

type CommitIterator interface {
	ForEach(fn func(Commit) error) error
	Close()
}

CommitIterator iterates over commits.

type ContextAwareRepository

type ContextAwareRepository interface {
	Repository
	// LogWithContext returns a commit iterator with context support.
	LogWithContext(ctx context.Context, opts *LogOptions) (CommitIterator, error)
}

ContextAwareRepository extends Repository with context-aware operations.

type FilePatch

type FilePatch interface {
	Chunks() []Chunk
}

FilePatch represents changes to a single file.

type GitOpener

type GitOpener struct{}

GitOpener opens git repositories using go-git.

func NewGitOpener

func NewGitOpener() *GitOpener

NewGitOpener creates a new GitOpener.

func (*GitOpener) PlainOpen

func (o *GitOpener) PlainOpen(path string) (Repository, error)

PlainOpen opens an existing git repository.

func (*GitOpener) PlainOpenWithDetect

func (o *GitOpener) PlainOpenWithDetect(path string) (Repository, error)

PlainOpenWithDetect opens a git repository, detecting .git in parent directories.

type LogOptions

type LogOptions struct {
	Since *time.Time
}

LogOptions configures the commit log query.

type Opener

type Opener interface {
	// PlainOpen opens an existing git repository.
	PlainOpen(path string) (Repository, error)
	// PlainOpenWithDetect opens a git repository, detecting .git in parent directories.
	PlainOpenWithDetect(path string) (Repository, error)
}

Opener opens git repositories.

func DefaultOpener

func DefaultOpener() Opener

DefaultOpener returns the default git opener.

type Patch

type Patch interface {
	FilePatches() []FilePatch
}

Patch represents a diff patch.

type Reference

type Reference interface {
	Hash() plumbing.Hash
}

Reference represents a git reference (branch, tag, HEAD).

type Repository

type Repository interface {
	// Head returns a reference to the HEAD commit.
	Head() (Reference, error)
	// Log returns a commit iterator starting from HEAD.
	Log(opts *LogOptions) (CommitIterator, error)
	// CommitObject returns the commit with the given hash.
	CommitObject(hash plumbing.Hash) (Commit, error)
	// Blame returns blame information for a file at a specific commit.
	Blame(commit Commit, path string) (*BlameResult, error)
}

Repository provides access to git repository operations.

type Tree

type Tree interface {
	// Diff computes differences between this tree and another.
	Diff(to Tree) (Changes, error)
}

Tree represents a git tree object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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