Documentation ¶
Index ¶
- Constants
- Variables
- func AddWorktree(tb testing.TB, cfg config.Cfg, repoPath string, worktreeName string)
- func AddWorktreeArgs(repoPath, worktreeName string) []string
- func BundleRepo(tb testing.TB, cfg config.Cfg, repoPath, bundlePath string, patterns ...string) []byte
- func CaptureHookEnv(tb testing.TB, cfg config.Cfg) string
- func ChecksumRepo(tb testing.TB, cfg config.Cfg, repoPath string) *git.Checksum
- func CommitEqual(tb testing.TB, expected, actual *gitalypb.GitCommit)
- func CreateObjectPool(tb testing.TB, ctx context.Context, cfg config.Cfg, ...) (*gitalypb.ObjectPool, string)
- func CreateRepository(tb testing.TB, ctx context.Context, cfg config.Cfg, ...) (*gitalypb.Repository, string)
- func Exec(tb testing.TB, cfg config.Cfg, args ...string) []byte
- func ExecOpts(tb testing.TB, cfg config.Cfg, execCfg ExecConfig, args ...string) []byte
- func FilesOrReftables[T any](files, reftable T) T
- func GetGitPackfileDirSize(tb testing.TB, repoPath string) int64
- func GetReferences(tb testing.TB, cfg config.Cfg, repoPath string, ...) []git.Reference
- func GetReplicaPath(tb testing.TB, ctx context.Context, cfg config.Cfg, repo storage.Repository, ...) string
- func GetSymbolicRef(tb testing.TB, cfg config.Cfg, repoPath string, refname git.ReferenceName) git.Reference
- func HTTPServer(tb testing.TB, ctx context.Context, gitCmdFactory git.CommandFactory, ...) int
- func InitRepoDir(tb testing.TB, storagePath, relativePath string) *gitalypb.Repository
- func ListObjects(tb testing.TB, cfg config.Cfg, repoPath string) []git.ObjectID
- func NewCommand(tb testing.TB, cfg config.Cfg, args ...string) *exec.Cmd
- func NewCommandFactory(tb testing.TB, cfg config.Cfg, opts ...git.ExecCommandFactoryOption) *git.ExecCommandFactory
- func NewObjectPoolName(tb testing.TB) string
- func NewRepositoryName(tb testing.TB) string
- func ObjectHashDependent[T any](tb testing.TB, valuesByObjectHash map[string]T) T
- func ObjectHashIsSHA256() bool
- func ObjectSize(tb testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID) int64
- func Pktlinef(t *testing.T, format string, a ...interface{}) string
- func RepositoryPath(tb testing.TB, pather RepositoryPather, components ...string) string
- func RequireObjectExists(tb testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID)
- func RequireObjectNotExists(tb testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID)
- func RequireTree(tb testing.TB, cfg config.Cfg, repoPath, treeish string, ...)
- func ResolveRevision(tb testing.TB, cfg config.Cfg, repoPath string, revision string) git.ObjectID
- func RewrittenRepository(tb testing.TB, ctx context.Context, cfg config.Cfg, ...) *gitalypb.Repository
- func SkipWithSHA256(tb testing.TB)
- func TestDeltaIslands(t *testing.T, cfg config.Cfg, repoPathToModify string, repoPathToRepack string, ...)
- func TestRepository(t *testing.T, cfg config.Cfg, getRepository GetRepositoryFunc)
- func WriteBlob(tb testing.TB, cfg config.Cfg, repoPath string, contents []byte) git.ObjectID
- func WriteBlobs(tb testing.TB, cfg config.Cfg, repoPath string, n int) []git.ObjectID
- func WriteCheckNewObjectExistsHook(tb testing.TB, repoPath string)
- func WriteCommit(tb testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCommitOption) git.ObjectID
- func WriteCustomHook(tb testing.TB, repoPath, name string, content []byte) string
- func WriteEnvToCustomHook(tb 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 WritePktlinef(t *testing.T, writer io.Writer, format string, args ...interface{})
- func WriteRef(tb testing.TB, cfg config.Cfg, repoPath string, ref git.ReferenceName, ...)
- func WriteTag(tb testing.TB, cfg config.Cfg, repoPath string, tagName string, ...) git.ObjectID
- func WriteTree(tb testing.TB, cfg config.Cfg, repoPath string, entries []TreeEntry) git.ObjectID
- type CountingCommandFactory
- func (f *CountingCommandFactory) CommandCount(cmd string) uint64
- func (f *CountingCommandFactory) New(ctx context.Context, repo storage.Repository, sc git.Command, ...) (*command.Command, error)
- func (f *CountingCommandFactory) NewWithoutRepo(ctx context.Context, sc git.Command, opts ...git.CmdOpt) (*command.Command, error)
- func (f *CountingCommandFactory) RequireCommandCount(tb testing.TB, cmd string, expected interface{})
- func (f *CountingCommandFactory) ResetCount()
- type CreateObjectPoolConfig
- type CreateRepositoryConfig
- type ExecConfig
- type GetReferencesConfig
- type GetReplicaPathConfig
- type GetRepositoryFunc
- type InterceptingCommandFactory
- func (f *InterceptingCommandFactory) GetExecutionEnvironment(ctx context.Context) git.ExecutionEnvironment
- func (f *InterceptingCommandFactory) GitVersion(ctx context.Context) (git.Version, error)
- func (f *InterceptingCommandFactory) HooksPath(ctx context.Context) string
- func (f *InterceptingCommandFactory) New(ctx context.Context, repo storage.Repository, sc git.Command, ...) (*command.Command, error)
- func (f *InterceptingCommandFactory) NewWithoutRepo(ctx context.Context, sc git.Command, opts ...git.CmdOpt) (*command.Command, error)
- type InterceptingCommandFactoryOption
- type ProtocolDetectingCommandFactory
- type RepositoryPathExecutor
- func (e RepositoryPathExecutor) Exec(ctx context.Context, cmd git.Command, opts ...git.CmdOpt) (*command.Command, error)
- func (e RepositoryPathExecutor) ExecAndWait(ctx context.Context, cmd git.Command, opts ...git.CmdOpt) error
- func (e RepositoryPathExecutor) GitVersion(ctx context.Context) (git.Version, error)
- func (e RepositoryPathExecutor) ObjectHash(ctx context.Context) (git.ObjectHash, error)
- func (e RepositoryPathExecutor) ReferenceBackend(ctx context.Context) (git.ReferenceBackend, error)
- type RepositoryPather
- type TreeEntry
- type WriteCommitOption
- func WithAlternateObjectDirectory(alternateObjectDir string) WriteCommitOption
- func WithAuthorDate(date time.Time) WriteCommitOption
- func WithAuthorName(name string) WriteCommitOption
- func WithBranch(branch string) WriteCommitOption
- func WithCommitterDate(date time.Time) WriteCommitOption
- func WithCommitterName(name string) WriteCommitOption
- func WithEncoding(encoding string) WriteCommitOption
- func WithMessage(message string) WriteCommitOption
- func WithParents(parents ...git.ObjectID) WriteCommitOption
- func WithReference(reference string) WriteCommitOption
- func WithTree(treeID git.ObjectID) WriteCommitOption
- func WithTreeEntries(entries ...TreeEntry) WriteCommitOption
- type WriteTagConfig
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" // Timezone is the Timezone of the default user. Timezone = "Asia/Shanghai" // TimezoneOffset is ISO 8601-like format of the default user Timezone. TimezoneOffset = "+0800" )
Variables ¶
var ( // DefaultCommitterName is the default name of the committer and author used to create // commits. DefaultCommitterName = "Scrooge McDuck" // DefaultCommitterMail is the default mail of the committer and author used to create // commits. DefaultCommitterMail = "scrooge@mcduck.com" // DefaultCommitTime is the default time used as written by WriteCommit(). DefaultCommitTime = time.Date(2019, 11, 3, 11, 27, 59, 0, time.FixedZone("UTC+1", 1*60*60)) // DefaultCommitterSignature is the default signature in the format like it would be present // in commits: "$name <$email> $unixtimestamp $timezone". DefaultCommitterSignature = fmt.Sprintf( "%s <%s> %s", DefaultCommitterName, DefaultCommitterMail, git.FormatSignatureTime(DefaultCommitTime), ) // DefaultCommitAuthor is the Protobuf message representation of the default committer and // author used to create commits. DefaultCommitAuthor = &gitalypb.CommitAuthor{ Name: []byte(DefaultCommitterName), Email: []byte(DefaultCommitterMail), Date: timestamppb.New(DefaultCommitTime), Timezone: []byte("+0100"), } )
var DefaultObjectHash = func() git.ObjectHash { if _, enabled := os.LookupEnv("GITALY_TEST_WITH_SHA256"); enabled { return git.ObjectHashSHA256 } return git.ObjectHashSHA1 }()
DefaultObjectHash is the default object hash used for running tests.
var DefaultReferenceBackend = func() git.ReferenceBackend { if val, enabled := os.LookupEnv("GIT_DEFAULT_REF_FORMAT"); enabled && val == "reftable" { return git.ReferenceBackendReftables } return git.ReferenceBackendFiles }()
DefaultReferenceBackend is the default reftable backend used for running tests.
var TestUser = &gitalypb.User{ Name: []byte("Jane Doe"), Email: []byte("janedoe@gitlab.com"), GlId: GlID, GlUsername: "janedoe", Timezone: Timezone, }
TestUser is the default user for tests.
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 BundleRepo ¶
func BundleRepo(tb testing.TB, cfg config.Cfg, repoPath, bundlePath string, patterns ...string) []byte
BundleRepo creates a bundle of a repository. `patterns` define the bundle contents as per `git-rev-list-args`. If there are no patterns then `--all` is assumed.
func CaptureHookEnv ¶
CaptureHookEnv wraps the 'gitaly-hooks' binary with a script that dumps the environment variables the update hook received prior to executing the actual hook. It returns the path to the file that the dump is written to.
func ChecksumRepo ¶
ChecksumRepo calculates the checksum of a repository.
func CommitEqual ¶
CommitEqual tests if two `GitCommit`s are equal
func CreateObjectPool ¶
func CreateObjectPool( tb testing.TB, ctx context.Context, cfg config.Cfg, source *gitalypb.Repository, optionalCfg ...CreateObjectPoolConfig, ) (*gitalypb.ObjectPool, string)
CreateObjectPool creates a new object pool from the given source repository. It returns the Protobuf representation used for gRPC calls. This can be passed either no or exactly one CreateObjectPoolConfig to influence how the pool will be created.
func CreateRepository ¶
func CreateRepository(tb testing.TB, ctx context.Context, cfg config.Cfg, configs ...CreateRepositoryConfig) (*gitalypb.Repository, string)
CreateRepository creates a new repository and returns it and its absolute path.
func FilesOrReftables ¶ added in v16.10.0
func FilesOrReftables[T any](files, reftable T) T
FilesOrReftables returns the files or reftable value based on which reference backend is currently being used.
func GetGitPackfileDirSize ¶
GetGitPackfileDirSize gets the number of 1k blocks of a git object directory
func GetReferences ¶ added in v16.4.0
func GetReferences(tb testing.TB, cfg config.Cfg, repoPath string, optionalCfg ...GetReferencesConfig) []git.Reference
GetReferences reads references in the Git repository.
func GetReplicaPath ¶
func GetReplicaPath(tb testing.TB, ctx context.Context, cfg config.Cfg, repo storage.Repository, opts ...GetReplicaPathConfig) string
GetReplicaPath retrieves the repository's replica path if the test has been run with Praefect in front of it. This is necessary if the test creates a repository through Praefect and peeks into the filesystem afterwards. Conn should be pointing to Praefect.
func GetSymbolicRef ¶ added in v16.4.0
func GetSymbolicRef(tb testing.TB, cfg config.Cfg, repoPath string, refname git.ReferenceName) git.Reference
GetSymbolicRef reads symbolic references in the Git repository.
func HTTPServer ¶
func HTTPServer(tb testing.TB, ctx context.Context, gitCmdFactory git.CommandFactory, repoPath string, middleware func(http.ResponseWriter, *http.Request, http.Handler)) int
HTTPServer 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 InitRepoDir ¶
func InitRepoDir(tb testing.TB, storagePath, relativePath string) *gitalypb.Repository
InitRepoDir creates a temporary directory for a repo, without initializing it
func ListObjects ¶
ListObjects returns a list of all object IDs in the repository.
func NewCommand ¶
NewCommand creates a new Git command ready for execution.
func NewCommandFactory ¶
func NewCommandFactory(tb testing.TB, cfg config.Cfg, opts ...git.ExecCommandFactoryOption) *git.ExecCommandFactory
NewCommandFactory creates a new Git command factory.
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 ObjectHashDependent ¶
ObjectHashDependent returns the value from the given map that is associated with the default object hash (e.g. "sha1", "sha256"). Fails in case the map doesn't contain the current object hash.
func ObjectHashIsSHA256 ¶
func ObjectHashIsSHA256() bool
ObjectHashIsSHA256 returns if the current default object hash is SHA256.
func ObjectSize ¶ added in v16.3.0
ObjectSize returns the size of the object identified by the given ID.
func RepositoryPath ¶
func RepositoryPath(tb testing.TB, pather RepositoryPather, components ...string) string
RepositoryPath returns the path of the given RepositoryPather. If any components are given, then the repository path and components are joined together.
func RequireObjectExists ¶
RequireObjectExists asserts that the given repository does contain an object with the specified object ID.
func RequireObjectNotExists ¶
RequireObjectNotExists asserts that the given repository does not contain an object with the specified object ID.
func RequireTree ¶
func RequireTree(tb 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 ResolveRevision ¶
ResolveRevision resolves the revision to an object ID.
func RewrittenRepository ¶
func RewrittenRepository(tb testing.TB, ctx context.Context, cfg config.Cfg, repository *gitalypb.Repository) *gitalypb.Repository
RewrittenRepository returns the repository as it would be received by a Gitaly after being rewritten by Praefect. This should be used when the repository is being accessed through the filesystem to ensure the access path is correct. If the test is not running with Praefect in front, it returns the an unaltered copy of repository.
func SkipWithSHA256 ¶ added in v16.4.0
SkipWithSHA256 skips the test in case the default object hash is SHA256.
func TestDeltaIslands ¶
func TestDeltaIslands( t *testing.T, cfg config.Cfg, repoPathToModify string, repoPathToRepack string, isPoolRepo bool, repack func() error, )
TestDeltaIslands checks whether functions that repack objects in a repository correctly set up delta islands. Based on https://github.com/git/git/blob/master/t/t5320-delta-islands.sh. Note that this function accepts two different repository paths: one repo to modify that shall grow the new references and objects, and one repository that we ultimately end up repacking. In the general case these should refer to the same repository, but for object pools these may be the pool member and the pool, respectively.
func TestRepository ¶
func TestRepository(t *testing.T, cfg config.Cfg, getRepository GetRepositoryFunc)
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(tb 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.
func WritePktlinef ¶
WritePktlinef formats the given format string and writes the pktline-formatted data into the writer.
func WriteRef ¶
func WriteRef(tb testing.TB, cfg config.Cfg, repoPath string, ref git.ReferenceName, oid git.ObjectID)
WriteRef writes a reference into the repository pointing to the given object ID.
func WriteTag ¶
func WriteTag( tb testing.TB, cfg config.Cfg, repoPath string, tagName string, targetRevision git.Revision, optionalConfig ...WriteTagConfig, ) git.ObjectID
WriteTag writes a new tag into the repository. This function either returns the tag ID in case an annotated tag was created, or otherwise the target object ID when a lightweight tag was created. Takes either no WriteTagConfig, in which case the default values will be used, or exactly one.
Types ¶
type CountingCommandFactory ¶
type CountingCommandFactory struct { git.CommandFactory // contains filtered or unexported fields }
CountingCommandFactory embeds a regular git command factory, but it keeps count of each call of New*() with their git command.
func NewCountingCommandFactory ¶
func NewCountingCommandFactory(tb testing.TB, cfg config.Cfg, opts ...git.ExecCommandFactoryOption) *CountingCommandFactory
NewCountingCommandFactory creates a CountingCommandFactory
func (*CountingCommandFactory) CommandCount ¶
func (f *CountingCommandFactory) CommandCount(cmd string) uint64
CommandCount returns the current count
func (*CountingCommandFactory) New ¶
func (f *CountingCommandFactory) New(ctx context.Context, repo storage.Repository, sc git.Command, opts ...git.CmdOpt) (*command.Command, error)
New creates a new git command and increments the command counter
func (*CountingCommandFactory) NewWithoutRepo ¶
func (f *CountingCommandFactory) NewWithoutRepo(ctx context.Context, sc git.Command, opts ...git.CmdOpt) (*command.Command, error)
NewWithoutRepo creates a new git command and increments the command counter
func (*CountingCommandFactory) RequireCommandCount ¶ added in v16.2.0
func (f *CountingCommandFactory) RequireCommandCount(tb testing.TB, cmd string, expected interface{})
RequireCommandCount checks if the count for the given command equals the expected count.
func (*CountingCommandFactory) ResetCount ¶
func (f *CountingCommandFactory) ResetCount()
ResetCount resets all counts to zero
type CreateObjectPoolConfig ¶
type CreateObjectPoolConfig struct { // ClientConn is the connection used to create the repository. If unset, the config is used // to dial the service. ClientConn *grpc.ClientConn // RelativePath sets the relative path of the repository in the storage. If unset, // the relative path is set to a randomly generated hashed storage path. RelativePath string // LinkRepositoryToObjectPool determines whether the repository shall be linked to the object // pool. LinkRepositoryToObjectPool bool }
CreateObjectPoolConfig can be used to tweak how CreateObjectPool behaves.
type CreateRepositoryConfig ¶
type CreateRepositoryConfig struct { // ClientConn is the connection used to create the repository. If unset, the config is used to // dial the service. ClientConn *grpc.ClientConn // Storage determines the storage the repository is created in. If unset, the first storage // from the config is used. Storage config.Storage // RelativePath sets the relative path of the repository in the storage. If unset, // the relative path is set to a randomly generated hashed storage path RelativePath string // Seed determines which repository is used to seed the created repository. If unset, the repository // is just created. The value should be one of the test repositories in _build/testrepos. Seed string // SkipCreationViaService skips creation of the repository by calling the respective RPC call. // In general, this should not be skipped so that we end up in a state that is consistent // and expected by both Gitaly and Praefect. It may be required though when testing at a // level where there are no gRPC services available. SkipCreationViaService bool // ObjectFormat overrides the object format used by the repository. ObjectFormat string }
CreateRepositoryConfig allows for configuring how the repository is created.
type ExecConfig ¶
type ExecConfig struct { // Stdin sets up stdin of the spawned command. Stdin io.Reader // Stdout sets up stdout of the spawned command. Note that `ExecOpts()` will not return any // output anymore if this field is set. Stdout io.Writer // Stderr sets up stderr of the spawned command. If this field is not set, the error is // dumped to test logs. Stderr io.Writer // Env contains environment variables that should be appended to the spawned command's // environment. Env []string // ExpectedExitCode is used to check the resulting exit code of the command. This can be used in case a command // is expected to return an error code. ExpectedExitCode int }
ExecConfig contains configuration for ExecOpts.
type GetReferencesConfig ¶ added in v16.4.0
type GetReferencesConfig = git.GetReferencesConfig
GetReferencesConfig is an alias of git.ReferencesConfig and can be passed to GetReferences to influence its default behaviour.
type GetReplicaPathConfig ¶
type GetReplicaPathConfig struct { // ClientConn is the connection used to create the repository. If unset, the config is used to // dial the service. ClientConn *grpc.ClientConn }
GetReplicaPathConfig allows for configuring the GetReplicaPath call.
type GetRepositoryFunc ¶
GetRepositoryFunc is used to get a clean test repository for the different implementations of the Repository interface in the common test suite TestRepository.
type InterceptingCommandFactory ¶
type InterceptingCommandFactory struct {
// contains filtered or unexported fields
}
InterceptingCommandFactory is a git.CommandFactory which intercepts all executions of Git commands with a custom script.
func NewInterceptingCommandFactory ¶
func NewInterceptingCommandFactory( tb testing.TB, ctx context.Context, cfg config.Cfg, generateScript func(git.ExecutionEnvironment) string, opts ...InterceptingCommandFactoryOption, ) *InterceptingCommandFactory
NewInterceptingCommandFactory creates a new command factory which intercepts Git commands. The given configuration must point to the real Git executable. The function will be executed to generate the script and receives as input the Git execution environment pointing to the real Git binary.
func (*InterceptingCommandFactory) GetExecutionEnvironment ¶
func (f *InterceptingCommandFactory) GetExecutionEnvironment(ctx context.Context) git.ExecutionEnvironment
GetExecutionEnvironment returns the execution environment of the intercetping command factory. The Git binary path will point to the intercepting script, while environment variables will point to the intercepted Git installation.
func (*InterceptingCommandFactory) GitVersion ¶
GitVersion returns the Git version as returned by the intercepted command.
func (*InterceptingCommandFactory) HooksPath ¶
func (f *InterceptingCommandFactory) HooksPath(ctx context.Context) string
HooksPath returns the path where hooks are stored. This returns the actual hooks path of the real Git command factory.
type InterceptingCommandFactoryOption ¶
type InterceptingCommandFactoryOption func(*interceptingCommandFactoryConfig)
InterceptingCommandFactoryOption is an option that can be passed to NewInterceptingCommandFactory.
func WithInterceptedVersion ¶
func WithInterceptedVersion() InterceptingCommandFactoryOption
WithInterceptedVersion will cause `GitVersion()` to use the intercepting Git command factory instead of the real Git command factory. This allows the caller to explicitly test version detection.
func WithRealCommandFactoryOptions ¶
func WithRealCommandFactoryOptions(opts ...git.ExecCommandFactoryOption) InterceptingCommandFactoryOption
WithRealCommandFactoryOptions is an option that allows the caller to pass options to the real git.ExecCommandFactory.
type ProtocolDetectingCommandFactory ¶
type ProtocolDetectingCommandFactory struct { git.CommandFactory // contains filtered or unexported fields }
ProtocolDetectingCommandFactory is an intercepting Git command factory that allows the protocol to be tested.
func NewProtocolDetectingCommandFactory ¶
func NewProtocolDetectingCommandFactory(tb testing.TB, ctx context.Context, cfg config.Cfg) ProtocolDetectingCommandFactory
NewProtocolDetectingCommandFactory returns a new ProtocolDetectingCommandFactory.
func (*ProtocolDetectingCommandFactory) ReadProtocol ¶
func (p *ProtocolDetectingCommandFactory) ReadProtocol(t *testing.T) string
ReadProtocol reads the protocol used by previous Git executions.
func (*ProtocolDetectingCommandFactory) Reset ¶
func (p *ProtocolDetectingCommandFactory) Reset(t *testing.T)
Reset resets previously recorded protocols.
type RepositoryPathExecutor ¶ added in v16.4.0
type RepositoryPathExecutor struct { storage.Repository // contains filtered or unexported fields }
RepositoryPathExecutor is a `git.RepositoryExecutor` that knows to execute commands in a Git repository identified by its absolute path.
func NewRepositoryPathExecutor ¶ added in v16.4.0
func NewRepositoryPathExecutor(tb testing.TB, cfg config.Cfg, repoPath string) RepositoryPathExecutor
NewRepositoryPathExecutor creates a new RepositoryPathExecutor for the given repository.
func (RepositoryPathExecutor) Exec ¶ added in v16.4.0
func (e RepositoryPathExecutor) Exec(ctx context.Context, cmd git.Command, opts ...git.CmdOpt) (*command.Command, error)
Exec executes a command in the given repository.
func (RepositoryPathExecutor) ExecAndWait ¶ added in v16.4.0
func (e RepositoryPathExecutor) ExecAndWait(ctx context.Context, cmd git.Command, opts ...git.CmdOpt) error
ExecAndWait executes a command in the given repository and waits for it to exit.
func (RepositoryPathExecutor) GitVersion ¶ added in v16.4.0
GitVersion determines the Git version used by the executor.
func (RepositoryPathExecutor) ObjectHash ¶ added in v16.4.0
func (e RepositoryPathExecutor) ObjectHash(ctx context.Context) (git.ObjectHash, error)
ObjectHash determines the object hash used by the repository.
func (RepositoryPathExecutor) ReferenceBackend ¶ added in v16.10.0
func (e RepositoryPathExecutor) ReferenceBackend(ctx context.Context) (git.ReferenceBackend, error)
ReferenceBackend detects the reference backend used by this repository.
type RepositoryPather ¶
RepositoryPather is an interface for repositories that know about their path.
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 WithAlternateObjectDirectory ¶
func WithAlternateObjectDirectory(alternateObjectDir string) WriteCommitOption
WithAlternateObjectDirectory will cause the commit to be written into the given alternate object directory. This can either be an absolute path or a relative path. In the latter case the path is considered to be relative to the repository path.
func WithAuthorDate ¶
func WithAuthorDate(date time.Time) WriteCommitOption
WithAuthorDate is an option for WriteCommit which will set the author date.
func WithAuthorName ¶
func WithAuthorName(name string) WriteCommitOption
WithAuthorName is an option for WriteCommit which will set the author name.
func WithBranch ¶
func WithBranch(branch string) WriteCommitOption
WithBranch is an option for WriteCommit which will cause it to update the given branch name to the new commit.
func WithCommitterDate ¶
func WithCommitterDate(date time.Time) WriteCommitOption
WithCommitterDate is an option for WriteCommit which will set the committer date.
func WithCommitterName ¶
func WithCommitterName(name string) WriteCommitOption
WithCommitterName is an option for WriteCommit which will set the committer name.
func WithEncoding ¶ added in v16.4.0
func WithEncoding(encoding string) WriteCommitOption
WithEncoding asks Git to set the commit message encoding to the given string.
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 WithReference ¶
func WithReference(reference string) WriteCommitOption
WithReference is an option for WriteCommit which will cause it to update the given reference to point to the new commit. This function requires the fully-qualified reference name.
func WithTree ¶
func WithTree(treeID git.ObjectID) WriteCommitOption
WithTree is an option for WriteCommit which will cause it to use the given object ID as the root tree of the resulting commit. as root tree 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.
type WriteTagConfig ¶
type WriteTagConfig struct { // Message is the message of an annotated tag. If left empty, then a lightweight tag will // be created. Message string // Force indicates whether existing tags with the same name shall be overwritten. Force bool // Date modifies the committer date that the tag should have. This only has an effect when writing // annotated tags. Date time.Time }
WriteTagConfig holds extra options for WriteTag.