Documentation ¶
Index ¶
- Constants
- Variables
- func AddWorktree(t testing.TB, cfg config.Cfg, repoPath string, worktreeName string)
- func AddWorktreeArgs(repoPath, worktreeName string) []string
- func AuthorEqual(t testing.TB, expected *gitalypb.CommitAuthor, actual *gitalypb.CommitAuthor)
- func CaptureHookEnv(t testing.TB) (string, func())
- func CloneBenchRepo(t testing.TB, cfg config.Cfg) (repo *gitalypb.Repository, repoPath string, cleanup func())
- func CloneRepoAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage, relativePath string) (*gitalypb.Repository, string, testhelper.Cleanup)
- func CloneRepoAtStorageRoot(t testing.TB, cfg config.Cfg, storageRoot, relativePath string) *gitalypb.Repository
- func CloneRepoWithWorktreeAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, testhelper.Cleanup)
- func CommitEqual(t testing.TB, expected, actual *gitalypb.GitCommit)
- func CreateCommitInAlternateObjectDirectory(t testing.TB, gitBin, repoPath, altObjectsDir string, cmd *exec.Cmd) (currentHead []byte)
- func CreateRemoteBranch(t testing.TB, cfg config.Cfg, repoPath, remoteName, branchName, ref string)
- func CreateTag(t testing.TB, cfg config.Cfg, repoPath, tagName, targetID string, ...) string
- func EnableGitProtocolV2Support(t testing.TB, cfg config.Cfg) (func() string, config.Cfg)
- func Exec(t testing.TB, cfg config.Cfg, args ...string) []byte
- func ExecStream(t testing.TB, cfg config.Cfg, stream io.Reader, args ...string) []byte
- func GetGitObjectDirSize(t testing.TB, repoPath string) int64
- func GetGitPackfileDirSize(t testing.TB, repoPath string) int64
- func GitObjectMustExist(t testing.TB, gitBin, repoPath, sha string)
- func GitObjectMustNotExist(t testing.TB, gitBin, repoPath, sha string)
- func GitServer(t testing.TB, cfg config.Cfg, repoPath string, ...) (int, func() error)
- func InitBareRepoAt(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, func())
- func InitRepoDir(t testing.TB, storagePath, relativePath string) *gitalypb.Repository
- func InitRepoWithWorktreeAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, func())
- func NewObjectPoolName(t testing.TB) string
- func NewRepositoryName(t testing.TB, bare bool) string
- func RemoteExists(t testing.TB, cfg config.Cfg, repoPath string, remoteName string) bool
- func RemoteUploadPackServer(ctx context.Context, t *testing.T, ...) (*httptest.Server, string)
- func RequireTree(t testing.TB, cfg config.Cfg, repoPath, treeish string, ...)
- func TestBitmapHasHashcache(t *testing.T, bitmap string)
- func TestDeltaIslands(t *testing.T, cfg config.Cfg, repoPath string, repack func() error)
- func TestRepository(t *testing.T, cfg config.Cfg, ...)
- func WriteBlob(t testing.TB, cfg config.Cfg, testRepoPath string, contents []byte) git.ObjectID
- func WriteBlobs(t testing.TB, cfg config.Cfg, testRepoPath string, n int) []string
- func WriteCheckNewObjectExistsHook(t testing.TB, gitBin, repoPath string)
- func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCommitOption) git.ObjectID
- func WriteCustomHook(t testing.TB, repoPath, name string, content []byte)
- func WriteEnvToCustomHook(t testing.TB, repoPath, hookName string) string
- func WritePktlineDelim(t *testing.T, writer io.Writer)
- func WritePktlineFlush(t *testing.T, writer io.Writer)
- func WritePktlineString(t *testing.T, writer io.Writer, data string)
- func WriteTree(t testing.TB, cfg config.Cfg, repoPath string, entries []TreeEntry) git.ObjectID
- type CreateTagOpts
- type TreeEntry
- type WriteCommitOption
Constants ¶
const ( // GlRepository is the default repository name for newly created test // repos. GlRepository = "project-1" // GlProjectPath is the default project path for newly created test // repos. GlProjectPath = "gitlab-org/gitlab-test" )
const (
// GlID is the ID of the default user.
GlID = "user-123"
)
Variables ¶
Functions ¶
func AddWorktree ¶
AddWorktree creates a worktree in the repository path for tests
func AddWorktreeArgs ¶
AddWorktreeArgs returns git command arguments for adding a worktree at the specified repo
func AuthorEqual ¶
func AuthorEqual(t testing.TB, expected *gitalypb.CommitAuthor, actual *gitalypb.CommitAuthor)
AuthorEqual tests if two `CommitAuthor`s are equal.
func CaptureHookEnv ¶
CaptureHookEnv creates a bogus 'update' Git hook to sniff out what environment variables get set for hooks.
func CloneBenchRepo ¶
func CloneBenchRepo(t testing.TB, cfg config.Cfg) (repo *gitalypb.Repository, repoPath string, cleanup func())
CloneBenchRepo creates a bare copy of the benchmarking test repository.
func CloneRepoAtStorage ¶
func CloneRepoAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage, relativePath string) (*gitalypb.Repository, string, testhelper.Cleanup)
CloneRepoAtStorage clones a new copy of test repository under a subdirectory in the storage root.
func CloneRepoAtStorageRoot ¶
func CloneRepoAtStorageRoot(t testing.TB, cfg config.Cfg, storageRoot, relativePath string) *gitalypb.Repository
CloneRepoAtStorageRoot clones a new copy of test repository under a subdirectory in the storage root.
func CloneRepoWithWorktreeAtStorage ¶
func CloneRepoWithWorktreeAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, testhelper.Cleanup)
CloneRepoWithWorktreeAtStorage creates a copy of the test repository with a worktree at the storage you want. This is allows you to run normal 'non-bare' Git commands.
func CommitEqual ¶
CommitEqual tests if two `GitCommit`s are equal
func CreateCommitInAlternateObjectDirectory ¶
func CreateCommitInAlternateObjectDirectory(t testing.TB, gitBin, repoPath, altObjectsDir string, cmd *exec.Cmd) (currentHead []byte)
CreateCommitInAlternateObjectDirectory runs a command such that its created objects will live in an alternate objects directory. It returns the current head after the command is run and the alternate objects directory path
func CreateRemoteBranch ¶
CreateRemoteBranch creates a new remote branch
func CreateTag ¶
func CreateTag(t testing.TB, cfg config.Cfg, repoPath, tagName, targetID string, opts *CreateTagOpts) string
CreateTag creates a new tag.
func EnableGitProtocolV2Support ¶
EnableGitProtocolV2Support replaces the git binary in config with a wrapper that allows the protocol to be tested. It returns a function to read the GIT_PROTOCOl environment variable created by the wrapper script, the modified configuration as well as a cleanup function.
func ExecStream ¶
ExecStream runs a git command with an input stream and returns the standard output, or fails.
func GetGitObjectDirSize ¶
GetGitObjectDirSize gets the number of 1k blocks of a git object directory
func GetGitPackfileDirSize ¶
GetGitPackfileDirSize gets the number of 1k blocks of a git object directory
func GitObjectMustExist ¶
GitObjectMustExist is a test assertion that fails unless the git repo in repoPath contains sha
func GitObjectMustNotExist ¶
GitObjectMustNotExist is a test assertion that fails unless the git repo in repoPath contains sha
func GitServer ¶
func GitServer(t testing.TB, cfg config.Cfg, repoPath string, middleware func(http.ResponseWriter, *http.Request, http.Handler)) (int, func() error)
GitServer starts an HTTP server with git-http-backend(1) as CGI handler. The repository is prepared such that git-http-backend(1) will serve it by creating the "git-daemon-export-ok" magic file.
func InitBareRepoAt ¶
func InitBareRepoAt(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, func())
InitBareRepoAt creates a new bare repository in the storage
func InitRepoDir ¶
func InitRepoDir(t testing.TB, storagePath, relativePath string) *gitalypb.Repository
InitRepoDir creates a temporary directory for a repo, without initializing it
func InitRepoWithWorktreeAtStorage ¶
func InitRepoWithWorktreeAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage) (*gitalypb.Repository, string, func())
InitRepoWithWorktreeAtStorage creates a new repository with a worktree in the storage
func NewObjectPoolName ¶
NewObjectPoolName returns a random pool repository name in format '@pools/[0-9a-z]{2}/[0-9a-z]{2}/[0-9a-z]{64}.git'.
func NewRepositoryName ¶
NewRepositoryName returns a random repository hash in format '@hashed/[0-9a-f]{2}/[0-9a-f]{2}/[0-9a-f]{64}(.git)?'.
func RemoteExists ¶
RemoteExists tests if the repository at repoPath has a Git remote named remoteName.
func RemoteUploadPackServer ¶
func RemoteUploadPackServer(ctx context.Context, t *testing.T, gitPath, repoName, httpToken, repoPath string) (*httptest.Server, string)
RemoteUploadPackServer implements two HTTP routes for git-upload-pack by copying stdin and stdout into and out of the git upload-pack command
func RequireTree ¶
func RequireTree(t testing.TB, cfg config.Cfg, repoPath, treeish string, expectedEntries []TreeEntry)
RequireTree looks up the given treeish and asserts that its entries match the given expected entries. Tree entries are checked recursively.
func TestBitmapHasHashcache ¶
TestBitmapHasHashcache checks if the named pack bitmap file contains "hash cache" data. See https://github.com/git/git/blob/master/Documentation/technical/bitmap-format.txt
func TestDeltaIslands ¶
TestDeltaIslands is based on the tests in https://github.com/git/git/blob/master/t/t5320-delta-islands.sh .
func TestRepository ¶
func TestRepository(t *testing.T, cfg config.Cfg, getRepository func(testing.TB, *gitalypb.Repository) git.Repository)
TestRepository tests an implementation of Repository.
func WriteBlob ¶
WriteBlob writes the given contents as a blob into the repository and returns its OID.
func WriteBlobs ¶
WriteBlobs writes n distinct blobs into the git repository's object database. Each object has the current time in nanoseconds as contents.
func WriteCheckNewObjectExistsHook ¶
WriteCheckNewObjectExistsHook writes a pre-receive hook which only succeeds if it can find the object in the quarantine directory. if GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES were not passed through correctly to the hooks, it will fail
func WriteCommit ¶
func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCommitOption) git.ObjectID
WriteCommit writes a new commit into the target repository.
func WriteCustomHook ¶
WriteCustomHook writes a hook in the repo/path.git/custom_hooks directory
func WriteEnvToCustomHook ¶
WriteEnvToCustomHook dumps the env vars that the custom hooks receives to a file
func WritePktlineDelim ¶
WritePktlineDelim writes the pktline-formatted delimiter into the writer.
func WritePktlineFlush ¶
WritePktlineFlush writes the pktline-formatted flush into the writer.
func WritePktlineString ¶
WritePktlineString writes the pktline-formatted data into the writer.
Types ¶
type CreateTagOpts ¶
CreateTagOpts holds extra options for CreateTag.
type TreeEntry ¶
type TreeEntry struct { // OID is the object ID the tree entry refers to. OID git.ObjectID // Mode is the file mode of the tree entry. Mode string // Path is the full path of the tree entry. Path string // Content is the content of the tree entry. Content string }
TreeEntry represents an entry of a git tree object.
type WriteCommitOption ¶
type WriteCommitOption func(*writeCommitConfig)
WriteCommitOption is an option which can be passed to WriteCommit.
func WithBranch ¶
func WithBranch(branch string) WriteCommitOption
WithBranch is an option for WriteCommit which will cause it to update the update the given branch name to the new commit.
func WithMessage ¶
func WithMessage(message string) WriteCommitOption
WithMessage is an option for WriteCommit which will set the commit message.
func WithParents ¶
func WithParents(parents ...git.ObjectID) WriteCommitOption
WithParents is an option for WriteCommit which will set the parent OIDs of the resulting commit.
func WithTreeEntries ¶
func WithTreeEntries(entries ...TreeEntry) WriteCommitOption
WithTreeEntries is an option for WriteCommit which will cause it to create a new tree and use it as root tree of the resulting commit.