localgit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package localgit creates a local git repo that can be used for testing code that uses a git.Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBranch

func DefaultBranch(dir string) string

Types

type Clients

type Clients func() (*LocalGit, v2.ClientFactory, error)

type LocalGit

type LocalGit struct {
	// Dir is the path to the base temp dir. Repos are at Dir/org/repo.
	Dir string
	// Git is the location of the git binary.
	Git string
	// InitialBranch is sent to git init
	InitialBranch string
}

LocalGit stores the repos in a temp dir. Create with New and delete with Clean.

func New

func New() (*LocalGit, v2.ClientFactory, error)

New creates a LocalGit and a client factory from a git.Client pointing at it.

func NewV2

func NewV2() (*LocalGit, v2.ClientFactory, error)

NewV2 creates a LocalGit and a v2 client factory pointing at it.

func (*LocalGit) AddCommit

func (lg *LocalGit) AddCommit(org, repo string, files map[string][]byte) error

AddCommit adds the files to a new commit in the repo.

func (*LocalGit) Checkout

func (lg *LocalGit) Checkout(org, repo, commitlike string) error

Checkout does git checkout.

func (*LocalGit) CheckoutNewBranch

func (lg *LocalGit) CheckoutNewBranch(org, repo, branch string) error

CheckoutNewBranch does git checkout -b.

func (*LocalGit) Clean

func (lg *LocalGit) Clean() error

Clean deletes the local git dir.

func (*LocalGit) MakeFakeRepo

func (lg *LocalGit) MakeFakeRepo(org, repo string) error

MakeFakeRepo creates the given repo and makes an initial commit.

func (*LocalGit) Merge

func (lg *LocalGit) Merge(org, repo, commitlike string) (string, error)

Merge does git merge.

func (*LocalGit) Rebase

func (lg *LocalGit) Rebase(org, repo, commitlike string) (string, error)

Rebase does git rebase.

func (*LocalGit) RevParse

func (lg *LocalGit) RevParse(org, repo, commitlike string) (string, error)

RevParse does git rev-parse.

func (*LocalGit) RmCommit

func (lg *LocalGit) RmCommit(org, repo string, files []string) error

RmCommit adds a commit that removes some files from the repo

Jump to

Keyboard shortcuts

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