gitrepo

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitrepo builds a local stand-in for a GitHub repository: a bare remote, a user's clone of it, and a pull request head published at refs/pull/<number>/head.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetProcessEnv

func SetProcessEnv() error

SetProcessEnv sets New's environment once for the whole process. A TestMain whose tests call t.Parallel MUST call it before m.Run, because New otherwise calls t.Setenv, which panics in a parallel test.

Types

type Repo

type Repo struct {
	// Dir is the user's clone.
	Dir string
	// RemoteDir is the bare repository that origin's URL is rewritten to.
	RemoteDir string
	// contains filtered or unexported fields
}

func New

func New(t *testing.T, owner, repo string, number int) *Repo

func NewWithBase

func NewWithBase(t *testing.T, owner, repo string, number int, base map[string]string) *Repo

NewWithBase is New with base also committed in the base, so the pull request can edit those files.

func (*Repo) AddPull

func (r *Repo) AddPull(number int)

AddPull publishes the current head as another pull request's head, for tests with several pull requests.

func (*Repo) BaseSHA

func (r *Repo) BaseSHA() string

func (*Repo) Git

func (r *Repo) Git(args ...string) string

Git runs git in the clone.

func (*Repo) HeadSHA

func (r *Repo) HeadSHA() string

func (*Repo) PushBase

func (r *Repo) PushBase(files map[string]string) string

PushBase commits files on top of the current base, off the pull request's history, and moves main to it, so the base is no longer the merge base.

func (*Repo) PushHead

func (r *Repo) PushHead(files map[string]string) string

PushHead commits files on top of the current pull request head and force-moves the head to it.

func (*Repo) RemoveHead

func (r *Repo) RemoveHead(paths ...string) string

RemoveHead commits the removal of paths on top of the current pull request head and force-moves the head to it.

func (*Repo) Snapshot

func (r *Repo) Snapshot() Snapshot

type Snapshot

type Snapshot struct {
	Status      string
	Head        string
	SymbolicRef string
	IndexSHA256 string
	Refs        map[string]string
}

func (Snapshot) DiffIgnoringLoupeRefs

func (s Snapshot) DiffIgnoringLoupeRefs(other Snapshot) []string

DiffIgnoringLoupeRefs lists every difference except under refs/loupe/, which capture is allowed to write.

Jump to

Keyboard shortcuts

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