gittest

package
v16.10.8 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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

View Source
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"),
	}
)
View Source
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.

View Source
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.

View Source
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

func AddWorktree(tb testing.TB, cfg config.Cfg, repoPath string, worktreeName string)

AddWorktree creates a worktree in the repository path for tests

func AddWorktreeArgs

func AddWorktreeArgs(repoPath, worktreeName string) []string

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

func CaptureHookEnv(tb testing.TB, cfg config.Cfg) string

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

func ChecksumRepo(tb testing.TB, cfg config.Cfg, repoPath string) *git.Checksum

ChecksumRepo calculates the checksum of a repository.

func CommitEqual

func CommitEqual(tb testing.TB, expected, actual *gitalypb.GitCommit)

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 Exec

func Exec(tb testing.TB, cfg config.Cfg, args ...string) []byte

Exec runs a git command and returns the standard output, or fails.

func ExecOpts

func ExecOpts(tb testing.TB, cfg config.Cfg, execCfg ExecConfig, args ...string) []byte

ExecOpts runs a git command with the given configuration.

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

func GetGitPackfileDirSize(tb testing.TB, repoPath string) int64

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

func ListObjects(tb testing.TB, cfg config.Cfg, repoPath string) []git.ObjectID

ListObjects returns a list of all object IDs in the repository.

func NewCommand

func NewCommand(tb testing.TB, cfg config.Cfg, args ...string) *exec.Cmd

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

func NewObjectPoolName(tb testing.TB) string

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

func NewRepositoryName(tb testing.TB) string

NewRepositoryName returns a random repository hash in format '@hashed/[0-9a-f]{2}/[0-9a-f]{2}/[0-9a-f]{64}.git'.

func ObjectHashDependent

func ObjectHashDependent[T any](tb testing.TB, valuesByObjectHash map[string]T) T

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

func ObjectSize(tb testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID) int64

ObjectSize returns the size of the object identified by the given ID.

func Pktlinef

func Pktlinef(t *testing.T, format string, a ...interface{}) string

Pktlinef formats the given formatting string into a pktline.

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

func RequireObjectExists(tb testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID)

RequireObjectExists asserts that the given repository does contain an object with the specified object ID.

func RequireObjectNotExists

func RequireObjectNotExists(tb testing.TB, cfg config.Cfg, repoPath string, objectID git.ObjectID)

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

func ResolveRevision(tb testing.TB, cfg config.Cfg, repoPath string, revision string) git.ObjectID

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

func SkipWithSHA256(tb testing.TB)

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

func WriteBlob(tb testing.TB, cfg config.Cfg, repoPath string, contents []byte) git.ObjectID

WriteBlob writes the given contents as a blob into the repository and returns its OID.

func WriteBlobs

func WriteBlobs(tb testing.TB, cfg config.Cfg, repoPath string, n int) []git.ObjectID

WriteBlobs writes n distinct blobs into the git repository's object database. Each object has the current time in nanoseconds as contents.

func WriteCheckNewObjectExistsHook

func WriteCheckNewObjectExistsHook(tb testing.TB, repoPath string)

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

func WriteCustomHook(tb testing.TB, repoPath, name string, content []byte) string

WriteCustomHook writes a hook in the repo/path.git/custom_hooks directory

func WriteEnvToCustomHook

func WriteEnvToCustomHook(tb testing.TB, repoPath, hookName string) string

WriteEnvToCustomHook dumps the env vars that the custom hooks receives to a file

func WritePktlineDelim

func WritePktlineDelim(t *testing.T, writer io.Writer)

WritePktlineDelim writes the pktline-formatted delimiter into the writer.

func WritePktlineFlush

func WritePktlineFlush(t *testing.T, writer io.Writer)

WritePktlineFlush writes the pktline-formatted flush into the writer.

func WritePktlineString

func WritePktlineString(t *testing.T, writer io.Writer, data string)

WritePktlineString writes the pktline-formatted data into the writer.

func WritePktlinef

func WritePktlinef(t *testing.T, writer io.Writer, format string, args ...interface{})

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.

func WriteTree

func WriteTree(tb testing.TB, cfg config.Cfg, repoPath string, entries []TreeEntry) git.ObjectID

WriteTree writes a new tree object to the given path. This function does not verify whether OIDs referred to by tree entries actually exist in the repository.

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

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

type GetRepositoryFunc func(t testing.TB, ctx context.Context) (git.Repository, string)

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

HooksPath returns the path where hooks are stored. This returns the actual hooks path of the real Git command factory.

func (*InterceptingCommandFactory) New

New creates a new Git command for the given repository using the intercepting script.

func (*InterceptingCommandFactory) NewWithoutRepo

func (f *InterceptingCommandFactory) NewWithoutRepo(ctx context.Context, sc git.Command, opts ...git.CmdOpt) (*command.Command, error)

NewWithoutRepo creates a new Git command using the intercepting script.

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

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

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

func (e RepositoryPathExecutor) GitVersion(ctx context.Context) (git.Version, error)

GitVersion determines the Git version used by the executor.

func (RepositoryPathExecutor) ObjectHash added in v16.4.0

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

type RepositoryPather interface {
	Path() (string, error)
}

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.

Jump to

Keyboard shortcuts

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