zeta

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COMMIT_EDITMSG = "COMMIT_EDITMSG"
	TAG_EDITMSG    = "TAG_EDITMSG"
	MERGE_MSG      = "MERGE_MSG"
)
View Source
const (
	NoSizeLimit = -1
	NoDepth     = 0
	NoDeepen    = 0
	AnyDeepen   = -1
)
View Source
const (
	ENV_ZETA_CORE_ACCELERATOR          = "ZETA_CORE_ACCELERATOR"
	ENV_ZETA_CORE_OPTIMIZE_STRATEGY    = "ZETA_CORE_OPTIMIZE_STRATEGY"
	ENV_ZETA_CORE_CONCURRENT_TRANSFERS = "ZETA_CORE_CONCURRENT_TRANSFERS"
	ENV_ZETA_CORE_SHARING_ROOT         = "ZETA_CORE_SHARING_ROOT"
	ENV_ZETA_CORE_PROMISOR             = "ZETA_CORE_PROMISOR"
	ENV_ZETA_AUTHOR_NAME               = "ZETA_AUTHOR_NAME"
	ENV_ZETA_AUTHOR_EMAIL              = "ZETA_AUTHOR_EMAIL"
	ENV_ZETA_AUTHOR_DATE               = "ZETA_AUTHOR_DATE"
	ENV_ZETA_COMMITTER_NAME            = "ZETA_COMMITTER_NAME"
	ENV_ZETA_COMMITTER_EMAIL           = "ZETA_COMMITTER_EMAIL"
	ENV_ZETA_COMMITTER_DATE            = "ZETA_COMMITTER_DATE"
	ENV_ZETA_MERGE_TEXT_DRIVER         = "ZETA_MERGE_TEXT_DRIVER"
	ENV_ZETA_EDITOR                    = "ZETA_EDITOR"
	ENV_ZETA_SSL_NO_VERIFY             = "ZETA_SSL_NO_VERIFY"
	ENV_ZETA_TRANSPORT_MAX_ENTRIES     = "ZETA_TRANSPORT_MAX_ENTRIES"
	ENV_ZETA_TRANSPORT_LARGE_SIZE      = "ZETA_TRANSPORT_LARGE_SIZE"
)
View Source
const (
	ENV_ZETA_EXTENSION_ARIA2C = "ZETA_EXTENSION_ARIA2C"
)
View Source
const (
	ENV_ZETA_EXTENSION_DRAGONFLY_GET = "ZETA_EXTENSION_DRAGONFLY_GET"
)
View Source
const (
	NUL = '\x00'
)
View Source
const (
	REBASE_MD = "REBASE-MD"
)
View Source
const (
	StashName plumbing.ReferenceName = "refs/stash"
)
View Source
const (
	// ZetaDirName this is a special folder where all the zeta stuff is.
	ZetaDirName = ".zeta"
)

Variables

View Source
var (
	ErrMissingKeys = errors.New("missing keys")
	ErrOnlyOneName = errors.New("only one config file at a time")
)
View Source
var (
	ErrUnrelatedHistories = errors.New("merge: refusing to merge unrelated histories")
	ErrHasConflicts       = errors.New("merge: there are conflicting files")
	ErrNotAncestor        = errors.New("merge-base: not ancestor")
)
View Source
var (
	ErrBranchHashExclusive  = errors.New("branch and Hash are mutually exclusive")
	ErrCreateRequiresBranch = errors.New("branch is mandatory when Create is used")
)
View Source
var (
	ErrWorktreeNotEmpty     = errors.New("worktree not empty")
	ErrWorktreeNotClean     = errors.New("worktree is not clean")
	ErrUnstagedChanges      = errors.New("worktree contains unstaged changes")
	ErrNonFastForwardUpdate = errors.New("non-fast-forward update")
)
View Source
var (
	ErrNotTreeNoder = errors.New("not tree noder")
	ErrNotIndexNode = errors.New("not index node")
)
View Source
var (
	// ErrNoChanges occurs when a commit is attempted using a clean
	// working tree, with no changes to be committed.
	ErrNoChanges            = errors.New("clean working tree")
	ErrNotAllowEmptyMessage = errors.New("not allow empty message")
	ErrNothingToCommit      = errors.New("nothing to commit")
)
View Source
var (
	// ErrDestinationExists in an Move operation means that the target exists on
	// the worktree.
	ErrDestinationExists = errors.New("destination exists")
	// ErrGlobNoMatches in an AddGlob if the glob pattern does not match any
	// files in the worktree.
	ErrGlobNoMatches = errors.New("glob pattern did not match any files")
)
View Source
var (
	ErrAborting = errors.New("aborting")
)
View Source
var (
	ErrHasUnstaged = errors.New("has unstaged")
)
View Source
var (
	ErrHashOrReference = errors.New("ambiguous options, only one of CommitHash or ReferenceName can be passed")
)
View Source
var (
	ErrHaveCommits = errors.New("have commits")
)
View Source
var (
	ErrMissingAuthor = errors.New("author field is required")
)
View Source
var (
	ErrNotAStashLikeCommit = errors.New("not a stash-like commit")
)
View Source
var (
	ErrNotAllowedRemoveCurrent = errors.New("not allowed remove HEAD")
)
View Source
var (
	ErrPushRejected = errors.New("push rejected")
)
View Source
var (
	W = tr.W // translate func wrap
)

Functions

func FindZetaDir

func FindZetaDir(cwd string) (string, string, error)

FindZetaDir return worktreeDir, zetaDir, err

func GetConfig

func GetConfig(opts *GetConfigOptions) error

func IsErrNotZetaDir

func IsErrNotZetaDir(err error) bool

func IsErrUnexpectedEOF

func IsErrUnexpectedEOF(err error) bool

func IsErrUnknownRevision

func IsErrUnknownRevision(err error) bool

func ListConfig

func ListConfig(opts *ListConfigOptions) error

func LookupAria2c

func LookupAria2c() (string, error)

func LookupDragonflyGet

func LookupDragonflyGet() (string, error)

func ParseBool

func ParseBool(str string) (bool, error)

ParseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.

func ReferencesSort

func ReferencesSort(rs References, order string) error

objectsize authordate committerdate creatordate taggerdate

func StatusName

func StatusName(c StatusCode) string

func UnsetConfig

func UnsetConfig(opts *UnsetConfigOptions) error

func UpdateConfig

func UpdateConfig(opts *UpdateConfigOptions) error

Types

type AddOptions

type AddOptions struct {
	// All equivalent to `git add -A`, update the index not only where the
	// working tree has a file matching `Path` but also where the index already
	// has an entry. This adds, modifies, and removes index entries to match the
	// working tree.  If no `Path` nor `Glob` is given when `All` option is
	// used, all files in the entire working tree are updated.
	All bool
	// Path is the exact filepath to the file or directory to be added.
	Path string
	// Glob adds all paths, matching pattern, to the index. If pattern matches a
	// directory path, all directory contents are added to the index recursively.
	Glob string
	// SkipStatus adds the path with no status check. This option is relevant only
	// when the `Path` option is specified and does not apply when the `All` option is used.
	// Notice that when passing an ignored path it will be added anyway.
	// When true it can speed up adding files to the worktree in very large repositories.
	SkipStatus bool
	DryRun     bool
}

AddOptions describes how an `add` operation should be performed

func (*AddOptions) Validate

func (o *AddOptions) Validate(r *Repository) error

Validate validates the fields and sets the default values.

type CatOptions

type CatOptions struct {
	Hash        string
	SizeMax     int64 // blob limit size
	Type        bool  // object type
	DisplaySize bool
	Textconv    bool
	FormatJSON  bool
	Verify      bool
}

type CheckIgnoreOption

type CheckIgnoreOption struct {
	Paths []string
	Stdin bool
	Z     bool
	JSON  bool
}

type CheckoutOptions

type CheckoutOptions struct {
	// Hash is the hash of the commit to be checked out. If used, HEAD will be
	// in detached mode. If Create is not used, Branch and Hash are mutually
	// exclusive.
	Hash plumbing.Hash
	// Branch to be checked out, if Branch and Hash are empty is set to `master`.
	Branch plumbing.ReferenceName
	// Create a new branch named Branch and start it at Hash.
	Create bool
	Force  bool
	Merge  bool
	First  bool
	One    bool
	Quiet  bool
}

CheckoutOptions describes how a checkout operation should be performed.

func (*CheckoutOptions) Validate

func (o *CheckoutOptions) Validate() error

Validate validates the fields and sets the default values.

type CherryPickOptions

type CherryPickOptions struct {
	From     string // From commit
	FF       bool
	Abort    bool
	Skip     bool
	Continue bool
}

type CleanOptions

type CleanOptions struct {
	// dry run
	DryRun bool
	// Dir recurses into nested directories.
	Dir bool
	// All removes all changes, even those excluded by gitignore.
	All bool
}

CleanOptions describes how a clean should be performed.

type CommitOptions

type CommitOptions struct {
	// All automatically stage files that have been modified and deleted, but
	// new files you have not told Git about are not affected.
	All bool
	// AllowEmptyCommits enable empty commits to be created. An empty commit
	// is when no changes to the tree were made, but a new commit message is
	// provided. The default behavior is false, which results in ErrEmptyCommit.
	AllowEmptyCommits bool
	// Author is the author's signature of the commit. If Author is empty the
	// Name and Email is read from the config, and time.Now it's used as When.
	Author object.Signature
	// Committer is the committer's signature of the commit. If Committer is
	// nil the Author signature is used.
	Committer object.Signature
	// Parents are the parents commits for the new commit, by default when
	// len(Parents) is zero, the hash of HEAD reference is used.
	Parents []plumbing.Hash
	// SignKey denotes a key to sign the commit with. A nil value here means the
	// commit will not be signed. The private key must be present and already
	// decrypted.
	SignKey *openpgp.Entity
	// Amend will create a new commit object and replace the commit that HEAD currently
	// points to. Cannot be used with All nor Parents.
	Amend             bool
	AllowEmptyMessage bool
	Message           []string
	File              string
}

CommitOptions describes how a commit operation should be performed.

func (*CommitOptions) Validate

func (o *CommitOptions) Validate(r *Repository) error

Validate validates the fields and sets the default values.

type CommitTreeOptions

type CommitTreeOptions struct {
	Tree plumbing.Hash
	// Author is the author's signature of the commit. If Author is empty the
	// Name and Email is read from the config, and time.Now it's used as When.
	Author object.Signature
	// Committer is the committer's signature of the commit. If Committer is
	// nil the Author signature is used.
	Committer object.Signature
	// Parents are the parents commits for the new commit, by default when
	// len(Parents) is zero, the hash of HEAD reference is used.
	Parents []plumbing.Hash
	// SignKey denotes a key to sign the commit with. A nil value here means the
	// commit will not be signed. The private key must be present and already
	// decrypted.
	SignKey *openpgp.Entity
	// Amend will create a new commit object and replace the commit that HEAD currently
	// points to. Cannot be used with All nor Parents.
	Message string
}

type DiffContextOptions

type DiffContextOptions struct {
	NameOnly        bool
	NameStatus      bool // name status
	NumStat         bool
	Stat            bool
	ShortStat       bool
	Staged          bool
	NewLine         byte
	MergeBase       string
	From            string
	To              string
	PathSpec        []string
	Textconv        bool
	UseColor        bool
	ThreeWayCompare bool
}

func (*DiffContextOptions) PatchContext

func (opts *DiffContextOptions) PatchContext(ctx context.Context, cs object.Changes) (*object.Patch, error)

type DoFetchOptions

type DoFetchOptions struct {
	Name        string
	Unshallow   bool
	Limit       int64
	Tag         bool
	Force       bool
	FetchAlways bool
	SkipLarges  bool
}

func (*DoFetchOptions) ReferenceName

func (opts *DoFetchOptions) ReferenceName() plumbing.ReferenceName

type ErrExitCode

type ErrExitCode struct {
	ExitCode int
	Message  string
}

func (*ErrExitCode) Error

func (e *ErrExitCode) Error() string

type ErrNotZetaDir

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

ErrNotExist commit not exist error

func (*ErrNotZetaDir) Error

func (err *ErrNotZetaDir) Error() string

type ErrUnknownRevision

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

func (*ErrUnknownRevision) Error

func (e *ErrUnknownRevision) Error() string

type FetchOptions

type FetchOptions struct {
	Target     plumbing.Hash
	DeepenFrom plumbing.Hash
	Have       plumbing.Hash
	Deepen     int
	Depth      int
	SizeLimit  int64
	SkipLarges bool
}

type FetchResult

type FetchResult struct {
	*transport.Reference
	FETCH_HEAD plumbing.Hash
}

type FileStatus

type FileStatus struct {
	// Staging is the status of a file in the staging area
	Staging StatusCode
	// Worktree is the status of a file in the worktree
	Worktree StatusCode
	// Extra contains extra information, such as the previous name in a rename
	Extra string
}

FileStatus contains the status of a file in the worktree

type ForEachReferenceOptions

type ForEachReferenceOptions struct {
	FormatJSON bool
	Order      string
	Pattern    []string
}

type GcOptions

type GcOptions struct {
	Prune time.Duration
}

type GetConfigOptions

type GetConfigOptions struct {
	System  bool
	Global  bool
	Local   bool
	ALL     bool
	Z       bool
	Keys    []string
	CWD     string
	Values  []string
	Verbose bool
}

type GrepOptions

type GrepOptions struct {
	// Patterns are compiled Regexp objects to be matched.
	Patterns []*regexp.Regexp
	// InvertMatch selects non-matching lines.
	InvertMatch bool
	// CommitHash is the hash of the commit from which worktree should be derived.
	CommitHash plumbing.Hash
	// ReferenceName is the branch or tag name from which worktree should be derived.
	ReferenceName plumbing.ReferenceName
	// PathSpecs are compiled Regexp objects of pathspec to use in the matching.
	PathSpecs []*regexp.Regexp
	// Size Limit
	Limit int64
}

GrepOptions describes how a grep should be performed.

func (*GrepOptions) Validate

func (o *GrepOptions) Validate(w *Worktree) error

Validate validates the fields and sets the default values.

TODO: deprecate in favor of Validate(r *Repository) in v6.

type GrepResult

type GrepResult struct {
	// FileName is the name of file which contains match.
	FileName string
	// LineNumber is the line number of a file at which a match was found.
	LineNumber int
	// Content is the content of the file at the matching line.
	Content string
	// TreeName is the name of the tree (reference name/commit hash) at
	// which the match was performed.
	TreeName string
}

GrepResult is structure of a grep result.

func (GrepResult) String

func (gr GrepResult) String() string

type InitOptions

type InitOptions struct {
	Branch    string
	Worktree  string
	MustEmpty bool
	Quiet     bool
	Verbose   bool
	Values    []string
}

type JsonTreeEntry

type JsonTreeEntry struct {
	Name string            `json:"name"`
	Size int64             `json:"size"`
	Mode filemode.FileMode `json:"mode"`
	Hash plumbing.Hash     `json:"hash"`
}

type ListConfigOptions

type ListConfigOptions struct {
	System  bool
	Global  bool
	Local   bool
	Z       bool
	CWD     string
	Values  []string
	Verbose bool
}

type ListFilesMode

type ListFilesMode int
const (
	ListFilesCached ListFilesMode = iota
	ListFilesDeleted
	ListFilesModified
	ListFilesOthers
	//ListFilesIgnored
	ListFilesStage
)

type LogOptions

type LogOptions struct {
	// When the From option is set the log will only contain commits
	// reachable from it. If this option is not set, HEAD will be used as
	// the default From.
	From plumbing.Hash

	// The default traversal algorithm is Depth-first search
	// set Order=LogOrderCommitterTime for ordering by committer time (more compatible with `git log`)
	// set Order=LogOrderBSF for Breadth-first search
	Order LogOrder

	// Show only those commits in which the specified file was inserted/updated.
	// It is equivalent to running `zeta log -- <file-name>`.
	// this field is kept for compatibility, it can be replaced with PathFilter
	FileName *string

	// Filter commits based on the path of files that are updated
	// takes file path as argument and should return true if the file is desired
	// It can be used to implement `zeta log -- <path>`
	// either <path> is a file path, or directory path, or a regexp of file/directory path
	PathFilter func(string) bool

	// Pretend as if all the refs in refs/, along with HEAD, are listed on the command line as <commit>.
	// It is equivalent to running `zeta log --all`.
	// If set on true, the From option will be ignored.
	All bool

	// Show commits more recent than a specific date.
	// It is equivalent to running `zeta log --since <date>` or `zeta log --after <date>`.
	Since *time.Time

	// Show commits older than a specific date.
	// It is equivalent to running `zeta log --until <date>` or `zeta log --before <date>`.
	Until *time.Time
}

LogOptions describes how a log action should be performed.

type LogOrder

type LogOrder int8
const (
	LogOrderDefault LogOrder = iota
	LogOrderDFS
	LogOrderDFSPost
	LogOrderBSF
	LogOrderCommitterTime
)

type LsFilesOptions

type LsFilesOptions struct {
	Mode  ListFilesMode
	Z     bool
	JSON  bool
	Paths []string
}

type LsTreeOptions

type LsTreeOptions struct {
	OnlyTrees bool
	Recurse   bool
	Tree      bool
	NewLine   byte
	Long      bool
	NameOnly  bool
	Abbrev    int
	Revision  string
	Paths     []string
	JSON      bool
}

func (*LsTreeOptions) Rev

func (opts *LsTreeOptions) Rev() string

func (*LsTreeOptions) ShortName

func (opts *LsTreeOptions) ShortName(oid plumbing.Hash) string

func (*LsTreeOptions) ShowTree

func (opts *LsTreeOptions) ShowTree(w io.Writer, t *object.Tree)

type Matcher

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

func NewMatcher

func NewMatcher(patterns []string) *Matcher

func (*Matcher) FsMatch

func (m *Matcher) FsMatch(fs vfs.VFS) error

func (*Matcher) Match

func (m *Matcher) Match(name string) bool

type MergeOptions

type MergeOptions struct {
	From string // From branch
	// Requires a merge to be fast forward only. If this is true, then a merge will
	// throw an error if ff is not possible.
	FFOnly                            bool
	FF                                bool
	Squash                            bool
	Signoff                           bool
	AllowUnrelatedHistories, Textconv bool
	Abort                             bool
	Continue                          bool
	Message                           []string
	File                              string
}

MergeOptions describes how a merge should be erformed

type MergeTreeOptions

type MergeTreeOptions struct {
	Branch1, Branch2, MergeBase                          string
	AllowUnrelatedHistories, Z, NameOnly, Textconv, JSON bool
}

type NewOptions

type NewOptions struct {
	Remote      string
	Branch      string
	TagName     string
	Commit      string
	Destination string
	Depth       int
	SparseDirs  []string
	Snapshot    bool
	SizeLimit   int64
	Values      []string
	One         bool
	Quiet       bool
	Verbose     bool
}

func (*NewOptions) Validate

func (opts *NewOptions) Validate() error

type NewTagOptions

type NewTagOptions struct {
	Name     string
	Target   string
	Message  []string
	File     string
	Annotate bool
	Force    bool
}

type OpenOptions

type OpenOptions struct {
	Worktree string
	Quiet    bool
	Verbose  bool
	Values   []string
}

type Printer

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

func NewPrinter

func NewPrinter(ctx context.Context) *Printer

func (*Printer) Close

func (p *Printer) Close() error

func (*Printer) LogOne

func (p *Printer) LogOne(c *object.Commit, refs []*ReferenceLite) (err error)

func (*Printer) UseColor

func (p *Printer) UseColor() bool

func (*Printer) Write

func (p *Printer) Write(b []byte) (n int, err error)

type ProgressBar

type ProgressBar interface {
	Add(int)
}

type PullOptions

type PullOptions struct {
	FF, FFOnly, Rebase, Squash, Unshallow, One bool
	Limit                                      int64
}

type PushOptions

type PushOptions struct {
	// Refspece: eg:
	//
	//  zeta push dev      // update branch or tag
	//  zeta push :dev     // delete branch or tag
	//  zeta push rev:dev  // update reference to rev
	//  zeta push          // update current branch
	Refspec     string
	PushObjects []string
	Tag         bool
	Force       bool
}

func (*PushOptions) Target

func (o *PushOptions) Target(name string) plumbing.ReferenceName

type RebaseMD

type RebaseMD struct {
	REBASE_HEAD plumbing.Hash          `toml:"REBASE_HEAD"` // REBASE_HEAD
	ONTO        plumbing.Hash          `toml:"ONTO"`        // ONTO Hash
	STOPPED     plumbing.Hash          `toml:"STOPPED"`     // STOPPED Hash
	LAST        plumbing.Hash          `toml:"LAST"`        // LAST
	MERGE_TREE  plumbing.Hash          `toml:"MERGE_TREE"`  // MERGE_TREE
	HEAD        plumbing.ReferenceName `toml:"HEAD"`        // HEAD aka CURRENT
}

type RebaseOptions

type RebaseOptions struct {
	Onto     string
	Abort    bool
	Continue bool
}

type Reference

type Reference struct {
	Name      plumbing.ReferenceName `json:"refname"`
	ShortName string                 `json:"refname_short"`
	Hash      plumbing.Hash          `json:"objectname"` // object name : commit/tag object ...
	Size      int                    `json:"objectsize"`
	Type      string                 `json:"objecttype"`
	Target    *object.Commit         `json:"commit,omitempty"`
	Tag       *object.Tag            `json:"tag,omitempty"`
	IsCurrent bool                   `json:"head,omitempty"`
}

type ReferenceLite

type ReferenceLite struct {
	Name      plumbing.ReferenceName
	ShortName plumbing.ReferenceName
	Target    plumbing.ReferenceName
}

type References

type References []*Reference

type ReferencesEx

type ReferencesEx struct {
	*refs.DB
	M map[plumbing.Hash][]*ReferenceLite
}

type RemoteOptions

type RemoteOptions struct {
	DryRun  bool
	Cached  bool
	Force   bool
	Recurse bool
}

type Repository

type Repository struct {
	*config.Config
	refs.Backend
	// contains filtered or unexported fields
}

func Init

func Init(ctx context.Context, opts *InitOptions) (*Repository, error)

func New

func New(ctx context.Context, opts *NewOptions) (*Repository, error)

create a new repo using zeta checkout command

func Open

func Open(ctx context.Context, opts *OpenOptions) (*Repository, error)

func (*Repository) Accelerator

func (r *Repository) Accelerator() config.Accelerator

func (*Repository) BaseDir

func (r *Repository) BaseDir() string

func (*Repository) Cat

func (r *Repository) Cat(ctx context.Context, opts *CatOptions) error

func (*Repository) CherryPick

func (r *Repository) CherryPick(ctx context.Context, opts *CherryPickOptions) error

func (*Repository) Close

func (r *Repository) Close() error

func (*Repository) CommitTree

func (r *Repository) CommitTree(ctx context.Context, opts *CommitTreeOptions) (plumbing.Hash, error)

func (*Repository) ConcurrentTransfers

func (r *Repository) ConcurrentTransfers() int

func (*Repository) CreateBranch

func (r *Repository) CreateBranch(ctx context.Context, newBranch, from string, force bool, fetchMissing bool) error

func (*Repository) Current

func (r *Repository) Current() (*plumbing.Reference, error)

func (*Repository) DbgPrint

func (r *Repository) DbgPrint(format string, args ...any)

func (*Repository) Debug

func (r *Repository) Debug(format string, args ...any)

func (*Repository) DoFetch

func (r *Repository) DoFetch(ctx context.Context, opts *DoFetchOptions) (plumbing.Hash, error)

DoFetch: Fetch reference or commit

func (*Repository) DoUpdate

func (r *Repository) DoUpdate(ctx context.Context, refname plumbing.ReferenceName, oldRev, newRev plumbing.Hash, committer *object.Signature, message string) error

DoUpdate: update-ref

func (*Repository) FetchObjects

func (r *Repository) FetchObjects(ctx context.Context, commit plumbing.Hash, skipLarges bool) error

func (*Repository) ForEachReference

func (r *Repository) ForEachReference(ctx context.Context, opts *ForEachReferenceOptions) error

func (*Repository) Gc

func (r *Repository) Gc(ctx context.Context, opts *GcOptions) error

func (*Repository) Grep

func (r *Repository) Grep(ctx context.Context, opts *GrepOptions) ([]GrepResult, error)

Grep performs grep on a repository.

func (*Repository) HashTo

func (r *Repository) HashTo(ctx context.Context, reader io.Reader, size int64) (oid plumbing.Hash, fragments bool, err error)

func (*Repository) IsAncestor

func (r *Repository) IsAncestor(ctx context.Context, a, b string) error

func (*Repository) IsCurrent

func (r *Repository) IsCurrent(refname plumbing.ReferenceName) bool

func (*Repository) IsExtreme

func (r *Repository) IsExtreme() bool

func (*Repository) ListBranch

func (r *Repository) ListBranch(ctx context.Context, pattern []string) error

func (*Repository) ListTag

func (r *Repository) ListTag(ctx context.Context, pattern []string) error

func (*Repository) Log

func (r *Repository) Log(ctx context.Context, revRange string, paths []string, formatJSON bool) error

func (*Repository) LsTree

func (r *Repository) LsTree(ctx context.Context, opts *LsTreeOptions) error

func (*Repository) LsTreeRecurse

func (r *Repository) LsTreeRecurse(ctx context.Context, opts *LsTreeOptions, t *object.Tree, m *Matcher) error

func (*Repository) MergeBase

func (r *Repository) MergeBase(ctx context.Context, revisions []string) error

func (*Repository) MergeTree

func (r *Repository) MergeTree(ctx context.Context, opts *MergeTreeOptions) error

func (*Repository) MoveBranch

func (r *Repository) MoveBranch(from, to string, force bool) error

func (*Repository) NewCommitter

func (r *Repository) NewCommitter() *object.Signature

func (*Repository) NewTag

func (r *Repository) NewTag(ctx context.Context, opts *NewTagOptions) error

func (*Repository) ODB

func (r *Repository) ODB() *odb.ODB

func (*Repository) PickAncestor

func (r *Repository) PickAncestor(ctx context.Context, oid plumbing.Hash, n int) (plumbing.Hash, error)

func (*Repository) Postflight

func (r *Repository) Postflight(ctx context.Context) error

func (*Repository) Push

func (r *Repository) Push(ctx context.Context, o *PushOptions) error

func (*Repository) RDB

func (r *Repository) RDB() refs.Backend

func (*Repository) ReferenceExists

func (r *Repository) ReferenceExists(ctx context.Context, refname string) error

func (*Repository) ReferenceResolve

func (r *Repository) ReferenceResolve(name plumbing.ReferenceName) (ref *plumbing.Reference, err error)

func (*Repository) ReferencesEx

func (r *Repository) ReferencesEx(ctx context.Context) (*ReferencesEx, error)

func (*Repository) RemoveBranch

func (r *Repository) RemoveBranch(branches []string, force bool) error

func (*Repository) RemoveTag

func (r *Repository) RemoveTag(tags []string) error

func (*Repository) Revision

func (r *Repository) Revision(ctx context.Context, branchOrTag string) (plumbing.Hash, error)

Revision resolve revision

https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection
We are not strictly compatible with Git, do not support combination mode, and do not support finding the second parent

eg: HEAD HEAD^^^^ HEAD~2 BRANCH or TAG Long-OID Short-OID

func (*Repository) RevisionEx

func (r *Repository) RevisionEx(ctx context.Context, revision string) (plumbing.Hash, plumbing.ReferenceName, error)

func (*Repository) ShowCurrent

func (r *Repository) ShowCurrent(w io.Writer) error

func (*Repository) SwitchBranch

func (r *Repository) SwitchBranch(ctx context.Context, branch string, so *SwitchOptions) error

func (*Repository) SwitchDetach

func (r *Repository) SwitchDetach(ctx context.Context, basePoint string, so *SwitchOptions) error

func (*Repository) SwitchNewBranch

func (r *Repository) SwitchNewBranch(ctx context.Context, newBranch string, basePoint string, so *SwitchOptions) error

func (*Repository) SwitchOrphan

func (r *Repository) SwitchOrphan(ctx context.Context, newBranch string, so *SwitchOptions) error

func (*Repository) Worktree

func (r *Repository) Worktree() *Worktree

func (*Repository) WriteEncoded

func (r *Repository) WriteEncoded(e object.Encoder) (oid plumbing.Hash, err error)

func (*Repository) ZetaDir

func (r *Repository) ZetaDir() string

type ResetMode

type ResetMode int8

ResetMode defines the mode of a reset operation.

const (
	// MixedReset resets the index but not the working tree (i.e., the changed
	// files are preserved but not marked for commit) and reports what has not
	// been updated. This is the default action.
	MixedReset ResetMode = iota
	// HardReset resets the index and working tree. Any changes to tracked files
	// in the working tree are discarded.
	HardReset
	// MergeReset resets the index and updates the files in the working tree
	// that are different between Commit and HEAD, but keeps those which are
	// different between the index and working tree (i.e. which have changes
	// which have not been added).
	//
	// If a file that is different between Commit and the index has unstaged
	// changes, reset is aborted.
	MergeReset
	// SoftReset does not touch the index file or the working tree at all (but
	// resets the head to <commit>, just like all modes do). This leaves all
	// your changed files "Changes to be committed", as git status would put it.
	SoftReset
)

type ResetOptions

type ResetOptions struct {
	// Commit, if commit is present set the current branch head (HEAD) to it.
	Commit plumbing.Hash
	// Mode, form resets the current branch head to Commit and possibly updates
	// the index (resetting it to the tree of Commit) and the working tree
	// depending on Mode. If empty MixedReset is used.
	Mode ResetMode

	// Fetch missing objects
	Fetch bool
	// One by one checkout files
	One bool

	Quiet bool
}

ResetOptions describes how a reset operation should be performed.

func (*ResetOptions) Validate

func (o *ResetOptions) Validate(r *Repository) error

Validate validates the fields and sets the default values.

type RestoreOptions

type RestoreOptions struct {
	Source   string
	Staged   bool
	Worktree bool
	Paths    []string
}

type ShowReferenceOptions

type ShowReferenceOptions struct {
	T           bool // tags default: true
	H           bool // heads default: true
	Dereference bool
}

TODO: support show-ref ???

type StageItem

type StageItem struct {
	Name  string            `json:"name"`
	Mode  filemode.FileMode `json:"mode"`
	Hash  plumbing.Hash     `json:"hash"`
	Stage index.Stage       `json:"stage"`
}

type StashPushOptions

type StashPushOptions struct {
	U bool
}

type Status

type Status map[string]*FileStatus

Status represents the current status of a Worktree. The key of the map is the path of the file.

func (Status) File

func (s Status) File(path string) *FileStatus

File returns the FileStatus for a given path, if the FileStatus doesn't exists a new FileStatus is added to the map using the path as key.

func (Status) IsAdded

func (s Status) IsAdded(path string) bool

IsAdded checks if file for given path is 'Added'.

func (Status) IsClean

func (s Status) IsClean() bool

IsClean returns true if all the files are in Unmodified status.

func (Status) IsDeleted

func (s Status) IsDeleted(path string) bool

IsDeleted checks if file for given path is 'Deleted'.

func (Status) IsModified

func (s Status) IsModified(path string) bool

IsModified checks if file for given path is 'Modified'.

func (Status) IsUntracked

func (s Status) IsUntracked(path string) bool

IsUntracked checks if file for given path is 'Untracked'

func (Status) String

func (s Status) String() string

type StatusCode

type StatusCode byte

StatusCode status code of a file in the Worktree

const (
	Unmodified         StatusCode = ' '
	Untracked          StatusCode = '?'
	Modified           StatusCode = 'M'
	Added              StatusCode = 'A'
	Deleted            StatusCode = 'D'
	Renamed            StatusCode = 'R'
	Copied             StatusCode = 'C'
	UpdatedButUnmerged StatusCode = 'U'
)

type StringArray

type StringArray []string

type SwitchOptions

type SwitchOptions struct {
	Force       bool // aka discardChanges
	Merge       bool
	ForceCreate bool
	Remote      bool
	Limit       int64
	// contains filtered or unexported fields
}

func (*SwitchOptions) Validate

func (so *SwitchOptions) Validate() error

type UnsetConfigOptions

type UnsetConfigOptions struct {
	System  bool
	Global  bool
	Keys    []string
	CWD     string
	Verbose bool
}

type UpdateConfigOptions

type UpdateConfigOptions struct {
	System        bool
	Global        bool
	Add           bool
	NameAndValues []string
	Type          string
	CWD           string
	Verbose       bool
}

type Worktree

type Worktree struct {
	// External excludes not found in the repository .gitignore/.zetaignore
	Excludes []ignore.Pattern

	*Repository
	// contains filtered or unexported fields
}

Worktree represents a zeta worktree.

func (*Worktree) Add

func (w *Worktree) Add(ctx context.Context, pathSpec []string, dryRun bool) error

func (*Worktree) AddGlob

func (w *Worktree) AddGlob(ctx context.Context, pattern string, dryRun bool) error

AddGlob adds all paths, matching pattern, to the index. If pattern matches a directory path, all directory contents are added to the index recursively. No error is returned if all matching paths are already staged in index.

func (*Worktree) AddTracked

func (w *Worktree) AddTracked(ctx context.Context, pathSpec []string, dryRun bool) error

func (*Worktree) AddWithOptions

func (w *Worktree) AddWithOptions(ctx context.Context, opts *AddOptions) error

AddWithOptions file contents to the index, updates the index using the current content found in the working tree, to prepare the content staged for the next commit.

It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with only part of the changes made to the working tree files applied, or remove paths that do not exist in the working tree anymore.

func (*Worktree) Checkout

func (w *Worktree) Checkout(ctx context.Context, opts *CheckoutOptions) error

func (*Worktree) Chmod

func (w *Worktree) Chmod(ctx context.Context, paths []string, mask bool, dryRun bool) error

func (*Worktree) Clean

func (w *Worktree) Clean(ctx context.Context, opts *CleanOptions) error

Clean the worktree by removing untracked files. An empty dir could be removed - this is what `zeta clean -f -d .` does.

func (*Worktree) Commit

func (w *Worktree) Commit(ctx context.Context, opts *CommitOptions) (plumbing.Hash, error)

Commit stores the current contents of the index in a new commit along with a log message from the user describing the changes.

func (*Worktree) DiffContext

func (w *Worktree) DiffContext(ctx context.Context, opts *DiffContextOptions, writer io.Writer) error

func (*Worktree) DiffTreeWithIndex

func (w *Worktree) DiffTreeWithIndex(ctx context.Context, oid plumbing.Hash, opts *DiffContextOptions, writer io.Writer) error

func (*Worktree) DiffTreeWithWorktree

func (w *Worktree) DiffTreeWithWorktree(ctx context.Context, oid plumbing.Hash, opts *DiffContextOptions, writer io.Writer) error

func (*Worktree) DoBatchCo

func (w *Worktree) DoBatchCo(ctx context.Context, oneByOne bool, revision string, r io.Reader) error

func (*Worktree) DoCheckIgnore

func (w *Worktree) DoCheckIgnore(ctx context.Context, opts *CheckIgnoreOption) error

func (*Worktree) DoPathCo

func (w *Worktree) DoPathCo(ctx context.Context, worktreeOnly bool, oid plumbing.Hash, pathSpec []string) error

func (*Worktree) Grep

func (w *Worktree) Grep(ctx context.Context, opts *GrepOptions) ([]GrepResult, error)

Grep performs grep on a worktree.

func (*Worktree) LsFiles

func (w *Worktree) LsFiles(ctx context.Context, opts *LsFilesOptions) error

func (*Worktree) Merge

func (w *Worktree) Merge(ctx context.Context, opts *MergeOptions) error

func (*Worktree) Pull

func (w *Worktree) Pull(ctx context.Context, opts *PullOptions) error

func (*Worktree) Rebase

func (w *Worktree) Rebase(ctx context.Context, opts *RebaseOptions) error

func (*Worktree) Remove

func (w *Worktree) Remove(ctx context.Context, patterns []string, opts *RemoteOptions) error

func (*Worktree) RemoveGlob

func (w *Worktree) RemoveGlob(pattern string) error

RemoveGlob removes all paths, matching pattern, from the index. If pattern matches a directory path, all directory contents are removed from the index recursively.

func (*Worktree) RemoveLegecy

func (w *Worktree) RemoveLegecy(path string) (plumbing.Hash, error)

RemoveLegecy removes files from the working tree and from the index.

func (*Worktree) Reset

func (w *Worktree) Reset(ctx context.Context, opts *ResetOptions) error

func (*Worktree) ResetSparsely

func (w *Worktree) ResetSparsely(ctx context.Context, opts *ResetOptions, bar ProgressBar) error

func (*Worktree) ResetSpec

func (w *Worktree) ResetSpec(ctx context.Context, oid plumbing.Hash, pathSpec []string) error

func (*Worktree) Restore

func (w *Worktree) Restore(ctx context.Context, opts *RestoreOptions) error

func (*Worktree) ShowStatus

func (w *Worktree) ShowStatus(status Status, short bool, z bool)

func (*Worktree) StashApply

func (w *Worktree) StashApply(ctx context.Context, stashRev string) error

func (*Worktree) StashClear

func (w *Worktree) StashClear(ctx context.Context) error

func (*Worktree) StashDrop

func (w *Worktree) StashDrop(ctx context.Context, stashRev string) error

func (*Worktree) StashList

func (w *Worktree) StashList(ctx context.Context) error

func (*Worktree) StashPop

func (w *Worktree) StashPop(ctx context.Context, stashRev string) error

func (*Worktree) StashPush

func (w *Worktree) StashPush(ctx context.Context, opts *StashPushOptions) error

func (*Worktree) StashShow

func (w *Worktree) StashShow(ctx context.Context, stashRev string) error

func (*Worktree) Stats

func (w *Worktree) Stats(ctx context.Context) error

func (*Worktree) Status

func (w *Worktree) Status(ctx context.Context, verbose bool) (Status, error)

Status returns the working tree status.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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