git

package
v0.0.0-...-33f01ad Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRepositoryNotFound     = errors.New("repository not found")
	ErrEmptyRemoteRepository  = errors.New("remote repository is empty")
	ErrAuthenticationRequired = errors.New("authentication required")
	ErrAuthorizationFailed    = errors.New("authorization failed")
	NoErrAlreadyUpToDate      = git.NoErrAlreadyUpToDate
)

Functions

func GetLatestCommitRemote

func GetLatestCommitRemote(opts ListOptions) (*string, error)

func IsInGitCommitHistory

func IsInGitCommitHistory(opts ListOptions, hash string) (bool, error)

func PlainOpen

func PlainOpen(path string) (*git.Repository, error)

PlainOpen opens a git repository from the given path. It detects if the repository is bare or a normal one. If the path doesn't contain a valid repository ErrRepositoryNotExists is returned

func Pull

func Pull(s *Repo, insecure bool) error

Types

type BaseSuite

type BaseSuite struct {
	fixtures.Suite
	Repository *git.Repository
	// contains filtered or unexported fields
}

func (*BaseSuite) BuildBasicRepository

func (s *BaseSuite) BuildBasicRepository()

func (*BaseSuite) GetBasicLocalRepositoryURL

func (s *BaseSuite) GetBasicLocalRepositoryURL() string

func (*BaseSuite) GetLocalRepositoryURL

func (s *BaseSuite) GetLocalRepositoryURL(f *fixtures.Fixture) string

func (*BaseSuite) NewRepository

func (s *BaseSuite) NewRepository(f *fixtures.Fixture) *git.Repository

NewRepository returns a new repository using the .git folder, if the fixture is tagged as worktree the filesystem from fixture is used, otherwise a new memfs filesystem is used as worktree.

func (*BaseSuite) SetUpSuite

func (s *BaseSuite) SetUpSuite()

type CloneOptions

type CloneOptions struct {
	URL                     string
	Auth                    transport.AuthMethod
	Insecure                bool
	UnsupportedCapabilities bool
	Branch                  string
	AlternativeBranch       *string
	GitCookies              []byte
	HomeDir                 string // The home directory to use for temporary files
}

type CreateOpt

type CreateOpt struct {
	Create bool
	Orphan bool
}

type IndexOptions

type IndexOptions struct {
	OriginRepo *Repo
	FromPath   string
	ToPath     string
}

type ListOptions

type ListOptions struct {
	URL        string
	Auth       transport.AuthMethod
	Insecure   bool
	Branch     string
	GitCookies []byte
	HomeDir    string // The home directory to use for temporary files
}

type Repo

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

func Clone

func Clone(opts CloneOptions) (*Repo, error)

func (*Repo) Branch

func (s *Repo) Branch(name string, createOpt *CreateOpt) error

Switch braches or create according to parameters passed in createOpt.

  • if createOpt is `nil` no branch are created and a `git checkout` is performed on branch specified by name
  • if creteOpt is different from nil and createOpt.Create is true a new branch is created checking out from the branch specified during clone - `git checkout -b branch-name`
  • if creteOpt is different from nil and both createOpt.Create and createOpt.Orphan are true a new branch is created from blank with no history or parents - `git switch --orphan branch-name`

func (*Repo) Cleanup

func (s *Repo) Cleanup() error

func (*Repo) Commit

func (s *Repo) Commit(path, msg string, opt *IndexOptions) (string, error)

func (*Repo) CurrentBranch

func (s *Repo) CurrentBranch() string

func (*Repo) Exists

func (s *Repo) Exists(path string) (bool, error)

func (*Repo) FS

func (s *Repo) FS() billy.Filesystem

func (*Repo) GetLatestCommit

func (s *Repo) GetLatestCommit(branch string) (string, error)

func (*Repo) Push

func (s *Repo) Push(downstream, branch string, insecure bool) error

func (*Repo) UpdateIndex

func (s *Repo) UpdateIndex(idx *IndexOptions) error

The function simulate the application of filemode of each from the origin repo (contained in "IndexOption.FromPath") to the destination repo (to files contained in IndexOption.ToPath) ---- git update-index --chmod

Jump to

Keyboard shortcuts

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