gitrepo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gitrepo provides operations on git repos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Hash    plumbing.Hash
	Message string
}

Commit represents a git commit.

type LocalRepository added in v0.1.1

type LocalRepository struct {
	Dir string
	// contains filtered or unexported fields
}

LocalRepository represents a git repository.

func NewRepository

func NewRepository(opts *RepositoryOptions) (*LocalRepository, error)

NewRepository provides access to a git repository based on the provided options.

If opts.Clone is CloneOptionNone, it opens an existing repository at opts.Dir. If opts.Clone is CloneOptionMaybe, it opens the repository if it exists, otherwise it clones from opts.RemoteURL. If opts.Clone is CloneOptionAlways, it always clones from opts.RemoteURL.

func (*LocalRepository) AddAll added in v0.1.1

func (r *LocalRepository) AddAll() (git.Status, error)

AddAll adds all pending changes from the working tree to the index, so that the changes can later be committed.

func (*LocalRepository) Commit added in v0.1.1

func (r *LocalRepository) Commit(msg string) error

Commit creates a new commit with the provided message and author information.

func (*LocalRepository) GetDir added in v0.1.1

func (r *LocalRepository) GetDir() string

GetDir returns the directory of the repository.

func (*LocalRepository) IsClean added in v0.1.1

func (r *LocalRepository) IsClean() (bool, error)

IsClean reports whether the working tree has no uncommitted changes.

func (*LocalRepository) Remotes added in v0.1.1

func (r *LocalRepository) Remotes() ([]*git.Remote, error)

Remotes returns the remotes within the repository.

type Repository

type Repository interface {
	AddAll() (git.Status, error)
	Commit(msg string) error
	IsClean() (bool, error)
	Remotes() ([]*git.Remote, error)
	GetDir() string
}

Repository defines the interface for git repository operations.

type RepositoryOptions

type RepositoryOptions struct {
	// Dir is the directory where the repository will reside locally. Required.
	Dir string
	// MaybeClone will try to clone the repository if it does not exist locally.
	// If set to true, RemoteURL must also be set. Optional.
	MaybeClone bool
	// RemoteURL is the URL of the remote repository to clone from. Required if Clone is not CloneOptionNone.
	RemoteURL string
	// CI is the type of Continuous Integration (CI) environment in which
	// the tool is executing.
	CI string
}

RepositoryOptions are used to configure a LocalRepository.

Jump to

Keyboard shortcuts

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