git

package
v1.11.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBinaryFile        = errors.New("binary file")
	ErrNotBinaryFile     = errors.New("not binary file")
	ErrMissingGitModules = errors.New("no .gitmodules file found")
	ErrInvalidGitModules = errors.New("invalid .gitmodules file")
	ErrNotSubmodule      = errors.New("path is not a submodule")
)
View Source
var (
	TerminateWalk error = errors.New("terminate walk")
)

Functions

func Fork

func Fork(repoPath, source string) error

func InitBare

func InitBare(path, defaultBranch string) error

Types

type CommitCount

type CommitCount struct {
	ByEmail map[string]int
}

type ConflictInfo

type ConflictInfo struct {
	Filename string
	Reason   string
}

type ErrMerge

type ErrMerge struct {
	Message     string
	Conflicts   []ConflictInfo
	HasConflict bool
	OtherError  error
}

func (ErrMerge) Error

func (e ErrMerge) Error() string

type GitRepo

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

func Open

func Open(path string, ref string) (*GitRepo, error)

func PlainOpen

func PlainOpen(path string) (*GitRepo, error)

func (*GitRepo) AnalyzeLanguages

func (g *GitRepo) AnalyzeLanguages(ctx context.Context) (LangBreakdown, error)

func (*GitRepo) Branch

func (g *GitRepo) Branch(name string) (*plumbing.Reference, error)

func (*GitRepo) Branches

func (g *GitRepo) Branches() ([]types.Branch, error)

func (*GitRepo) Commit

func (g *GitRepo) Commit(h plumbing.Hash) (*object.Commit, error)

func (*GitRepo) Commits

func (g *GitRepo) Commits(offset, limit int) ([]*object.Commit, error)

func (*GitRepo) DeleteBranch

func (g *GitRepo) DeleteBranch(branch string) error

func (*GitRepo) Diff

func (g *GitRepo) Diff() (*types.NiceDiff, error)

func (*GitRepo) DiffTree

func (g *GitRepo) DiffTree(commit1, commit2 *object.Commit) (*types.DiffTree, error)

func (*GitRepo) FileContentN

func (g *GitRepo) FileContentN(path string, cap int64) ([]byte, error)

func (*GitRepo) FileTree

func (g *GitRepo) FileTree(ctx context.Context, path string) ([]types.NiceTree, error)

func (*GitRepo) FindMainBranch

func (g *GitRepo) FindMainBranch() (string, error)

func (*GitRepo) FormatPatch

func (g *GitRepo) FormatPatch(base, commit2 *object.Commit) (string, []types.FormatPatch, error)

func (*GitRepo) MergeCheck

func (g *GitRepo) MergeCheck(patchData string, targetBranch string) error

func (*GitRepo) MergeWithOptions

func (g *GitRepo) MergeWithOptions(patchData string, targetBranch string, opts MergeOptions) error

func (*GitRepo) RawContent

func (g *GitRepo) RawContent(path string) ([]byte, error)

func (*GitRepo) RefUpdateMeta

func (g *GitRepo) RefUpdateMeta(line PostReceiveLine) (RefUpdateMeta, error)

func (*GitRepo) Refresh

func (g *GitRepo) Refresh() error

re-open a repository and update references

func (*GitRepo) ResolveRevision

func (g *GitRepo) ResolveRevision(revStr string) (*object.Commit, error)

func (*GitRepo) SetDefaultBranch

func (g *GitRepo) SetDefaultBranch(branch string) error

func (*GitRepo) Submodule

func (g *GitRepo) Submodule(path string) (*config.Submodule, error)

func (*GitRepo) Submodules

func (g *GitRepo) Submodules() (*config.Modules, error)

read and parse .gitmodules

func (*GitRepo) Sync

func (g *GitRepo) Sync() error

func (*GitRepo) Tags

func (g *GitRepo) Tags() ([]object.Tag, error)

func (*GitRepo) TotalCommits

func (g *GitRepo) TotalCommits() (int, error)

func (*GitRepo) TrackHiddenRemoteRef

func (g *GitRepo) TrackHiddenRemoteRef(forkRef, remoteRef string) error

TrackHiddenRemoteRef tracks a hidden remote in the repository. For example, if the feature branch on the fork (forkRef) is feature-1, and the remoteRef, i.e. the branch we want to merge into, is main, this will result in a refspec:

+refs/heads/main:refs/hidden/feature-1/main

func (*GitRepo) Walk

func (g *GitRepo) Walk(
	ctx context.Context,
	root string,
	cb callback,
) error

func (*GitRepo) WriteTar

func (g *GitRepo) WriteTar(w io.Writer, prefix string) error

WriteTar writes itself from a tree into a binary tar file format. prefix is root folder to be appended.

type LangBreakdown

type LangBreakdown map[string]int64

type MergeCheckCache

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

func (*MergeCheckCache) Get

func (m *MergeCheckCache) Get(g *GitRepo, patch string, targetBranch string) (error, bool)

func (*MergeCheckCache) Set

func (m *MergeCheckCache) Set(g *GitRepo, patch string, targetBranch string, mergeCheck error)

type MergeOptions

type MergeOptions struct {
	CommitMessage  string
	CommitBody     string
	AuthorName     string
	AuthorEmail    string
	CommitterName  string
	CommitterEmail string
	FormatPatch    bool
}

MergeOptions specifies the configuration for a merge operation

type PostReceiveLine

type PostReceiveLine struct {
	OldSha plumbing.Hash // old sha of reference being updated
	NewSha plumbing.Hash // new sha of reference being updated
	Ref    string        // the reference being updated
}

func ParsePostReceive

func ParsePostReceive(buf io.Reader) ([]PostReceiveLine, error)

type RefUpdateMeta

type RefUpdateMeta struct {
	CommitCount   CommitCount
	IsDefaultRef  bool
	LangBreakdown LangBreakdown
}

func (RefUpdateMeta) AsRecord

Source Files

  • branch.go
  • cmd.go
  • diff.go
  • fork.go
  • git.go
  • language.go
  • last_commit.go
  • merge.go
  • post_receive.go
  • repo.go
  • tag.go
  • tree.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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