git2go

package
v16.2.11 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LegacyErrPrefixInvalidBranch        = "Invalid branch"
	LegacyErrPrefixInvalidSubmodulePath = "Invalid submodule path"
	LegacyErrPrefixFailedCommit         = "Failed to create commit"
)

Error strings present in the legacy Ruby implementation

View Source
const (
	// MergeRecursionLimit limits how many virtual merge bases are computed
	// in a recursive merge.
	MergeRecursionLimit = 20
)

Variables

View Source
var (
	// ErrInvalidArgument is returned in case the merge arguments are invalid.
	ErrInvalidArgument = errors.New("invalid parameters")

	// BinaryName is the name of the gitaly-git2go binary.
	BinaryName = "gitaly-git2go"
)

Functions

func SerializableError

func SerializableError(err error) error

SerializableError returns an error that is Gob serializable. Registered types are serialized directly. Unregistered types are transformed in to an opaque error using their error message. Wrapped errors remain unwrappable.

Types

type CherryPickCommand

type CherryPickCommand struct {
	// Repository is the path where to execute the cherry-pick.
	Repository string
	// CommitterName is the committer name for the resulting commit.
	CommitterName string
	// CommitterMail is the committer mail for the resulting commit.
	CommitterMail string
	// CommitterDate is the committer date of revert commit.
	CommitterDate time.Time
	// Message is the message to be used for the resulting commit.
	Message string
	// Ours is the commit that the revert is applied to.
	Ours string
	// Commit is the commit that is to be picked.
	Commit string
	// Mainline is the parent to be considered the mainline
	Mainline uint
	// SigningKey is a path to the key to sign commit using OpenPGP
	SigningKey string
}

CherryPickCommand contains parameters to perform a cherry-pick.

type CommitNotFoundError

type CommitNotFoundError struct {
	// Revision used to lookup the commit
	Revision string
}

CommitNotFoundError indicates that the given commit rev could not be found.

func (CommitNotFoundError) Error

func (err CommitNotFoundError) Error() string

type ConflictingFilesError

type ConflictingFilesError struct {
	// ConflictingFiles is the set of files which have conflicts.
	ConflictingFiles []string
}

ConflictingFilesError is an error raised when there are conflicting files.

func (ConflictingFilesError) Error

func (err ConflictingFilesError) Error() string

type EmptyError

type EmptyError struct{}

EmptyError indicates the command, for example cherry-pick, did result in no changes, so the result is empty.

func (EmptyError) Error

func (err EmptyError) Error() string

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor executes gitaly-git2go.

func NewExecutor

func NewExecutor(cfg config.Cfg, gitCmdFactory git.CommandFactory, locator storage.Locator) *Executor

NewExecutor returns a new gitaly-git2go executor using binaries as configured in the given configuration.

func (*Executor) CherryPick

func (b *Executor) CherryPick(ctx context.Context, repo storage.Repository, m CherryPickCommand) (git.ObjectID, error)

CherryPick performs a cherry-pick via gitaly-git2go.

func (*Executor) Merge

Merge performs a merge via gitaly-git2go.

func (*Executor) Rebase

Rebase performs the rebase via gitaly-git2go

func (*Executor) Resolve

Resolve will attempt merging and resolving conflicts for the provided request

func (*Executor) Revert

Revert reverts a commit via gitaly-git2go.

type FeatureFlag

type FeatureFlag struct {
	// MetadataKey is the metadata key of the feature flag.
	MetadataKey string
	// Name is the name of the feature flag.
	Name string
	// Value is the value of the feature flag.
	Value bool
}

FeatureFlag is a feature flag state as seen by the `gitaly-git2go featureflag` test subcommand.

type FeatureFlags

type FeatureFlags struct {
	// Flags is the set of feature flags observed by the command.
	Flags []FeatureFlag
	// Err is set if an error occurred. Err must exist on all gob serialized
	// results so that any error can be returned.
	Err error
}

FeatureFlags is a struct only used by tests to confirm that feature flags are being properly propagated from the git2go Executor to the gitaly-git2go binary

type HasConflictsError

type HasConflictsError struct{}

HasConflictsError is used when a change, for example a revert, could not be applied due to a conflict.

func (HasConflictsError) Error

func (err HasConflictsError) Error() string

type IndexError

type IndexError struct {
	Path string
	Type IndexErrorType
}

IndexError is a well-defined error that was produced by performing an invalid operation on the index.

func (IndexError) Error

func (err IndexError) Error() string

Error returns the error message associated with the error type.

func (IndexError) Proto

func (err IndexError) Proto() *gitalypb.IndexError

Proto returns the Protobuf representation of this error.

func (IndexError) StructuredError

func (err IndexError) StructuredError() structerr.Error

StructuredError returns the structured error.

type IndexErrorType

type IndexErrorType uint

IndexErrorType specifies which of the known index error types has occurred.

const (
	// ErrDirectoryExists represent a directory exists error.
	ErrDirectoryExists IndexErrorType = iota
	// ErrDirectoryTraversal represent a directory traversal error.
	ErrDirectoryTraversal
	// ErrEmptyPath represent an empty path error.
	ErrEmptyPath
	// ErrFileExists represent a file exists error.
	ErrFileExists
	// ErrFileNotFound represent a file not found error.
	ErrFileNotFound
	// ErrInvalidPath represent an invalid path error.
	ErrInvalidPath
)

type InvalidArgumentError

type InvalidArgumentError string

InvalidArgumentError is returned when an invalid argument is provided.

func (InvalidArgumentError) Error

func (err InvalidArgumentError) Error() string

type MergeCommand

type MergeCommand struct {
	// Repository is the path to execute merge in.
	Repository string
	// AuthorName is the author name of merge commit.
	AuthorName string
	// AuthorMail is the author mail of merge commit.
	AuthorMail string
	// AuthorDate is the author date of merge commit.
	AuthorDate time.Time
	// CommitterName. Can be empty if all Committer* vars are empty.
	// In that case AuthorName is used instead.
	CommitterName string
	// CommitterMail. Can be empty if all Committer* vars are empty.
	// In that case AuthorMail is used instead.
	CommitterMail string
	// CommitterDate. Can be empty if all Committer* vars are empty.
	// In that case AuthorDate is used instead.
	CommitterDate time.Time
	// Message is the message to be used for the merge commit.
	Message string
	// Ours is the commit into which theirs is to be merged.
	Ours string
	// Theirs is the commit that is to be merged into ours.
	Theirs string
	// AllowConflicts controls whether conflicts are allowed. If they are,
	// then conflicts will be committed as part of the result.
	AllowConflicts bool
	// Squash controls whether to perform squash merge.
	// If set to `true`, then the resulting commit will have `Ours` as its only parent.
	// Otherwise, a merge commit will be created with `Ours` and `Theirs` as its parents.
	Squash bool
	// SigningKey is a path to the key to sign commit using OpenPGP
	SigningKey string
}

MergeCommand contains parameters to perform a merge.

type MergeResult

type MergeResult struct {
	// CommitID is the object ID of the generated merge commit.
	CommitID string
}

MergeResult contains results from a merge.

type RebaseCommand

type RebaseCommand struct {
	// Repository is the path to execute rebase in.
	Repository string
	// Committer contains the the committer signature.
	Committer Signature
	// BranchName is the branch that is rebased. Deprecated, can be removed in the next release.
	BranchName string
	// UpstreamRevision is the revision where the branch is rebased onto. Deprecated, can be
	// removed in the next release.
	UpstreamRevision string
	// CommitID is the object ID of the commit that shall be rebased. Deprecates BranchName.
	CommitID git.ObjectID
	// UpstreamCommitID is the object ID of the commit which is considered to be the
	// upstream branch. This parameter determines both the commit onto which we're
	// about to rebase, which is the merge base of the upstream commit and rebased
	// commit, and which commits should be rebased, which is the commit range
	// upstream..commit. Deprecates the UpstreamRevision.
	UpstreamCommitID git.ObjectID
	// SkipEmptyCommits will cause commits which have already been applied on the target branch
	// and which are thus empty to be skipped. If unset, empty commits will cause the rebase to
	// fail.
	SkipEmptyCommits bool
	// SigningKey is a path to the key to sign commit using OpenPGP
	SigningKey string
}

RebaseCommand contains parameters to rebase a branch.

type ResolveCommand

type ResolveCommand struct {
	MergeCommand
	Resolutions []conflict.Resolution
}

ResolveCommand contains arguments to perform a merge commit and resolve any conflicts produced from that merge commit

type ResolveResult

type ResolveResult struct {
	MergeResult

	// Err is set if an error occurred. Err must exist on all gob serialized
	// results so that any error can be returned.
	Err error
}

ResolveResult returns information about the successful merge and resolution

type Result

type Result struct {
	// CommitID is the result of the call.
	CommitID string
	// Err is set if an error occurred. Err must exist on all gob serialized
	// results so that all errors can be returned.
	Err error
}

Result is the serialized result.

type RevertCommand

type RevertCommand struct {
	// Repository is the path to execute the revert in.
	Repository string
	// AuthorName is the author name of revert commit.
	AuthorName string
	// AuthorMail is the author mail of revert commit.
	AuthorMail string
	// AuthorDate is the author date of revert commit.
	AuthorDate time.Time
	// Message is the message to be used for the revert commit.
	Message string
	// Ours is the commit that the revert is applied to.
	Ours string
	// Revert is the commit to be reverted.
	Revert string
	// Mainline is the parent to be considered the mainline
	Mainline uint
	// SigningKey is a path to the key to sign commit using OpenPGP
	SigningKey string
}

RevertCommand contains parameters required to execute a revert via gitaly-git2go.

type Signature

type Signature struct {
	// Name of the author or the committer.
	Name string
	// Email of the author or the committer.
	Email string
	// When is the time of the commit.
	When time.Time
}

Signature represents a commits signature.

func NewSignature

func NewSignature(name, email string, when time.Time) Signature

NewSignature creates a new sanitized signature.

type UnknownIndexError

type UnknownIndexError string

UnknownIndexError is an unspecified error that was produced by performing an invalid operation on the index.

func (UnknownIndexError) Error

func (err UnknownIndexError) Error() string

Error returns the error message of the unknown index error.

Jump to

Keyboard shortcuts

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