Help us shape the future of Go! Take the 2026 Go Developer Survey

gitbackend

package
v0.99.9 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 33 Imported by: 3

Documentation

Overview

Package gitbackend provides local Git repository operations behind two interchangeable backends, selected through one factory:

backend, err := gitbackend.NewGitBackend(gitbackend.Options{Type: "native"})

Leaving Type empty auto-selects: the native backend when a git binary is available, the pure-Go fallback otherwise.

Backends

  • native shells out to the local git binary and has the fullest feature set, including the operations go-git does not model (Rebase, Stash, CherryPick, RunRaw). Child processes run under an argv whitelist (native_argguard), output is parsed from NUL/TAB delimited formats so titles containing "|" and friends cannot skew fields, and merge conflicts are detected from git's exit codes and markers rather than error strings.
  • gogit is pure Go (go-git/v5) and needs no git binary — suited to distroless containers and read-heavy automation. Operations beyond go-git's model return ErrNotSupported instead of misbehaving, so callers can feature-detect with errors.Is.

Both implement the GitBackend interface (iface.go); Repository (repository.go) wraps a working copy with the day-to-day surface — Fetch/Push, status, diff, branch/tag/file operations — and must be Closed to release filesystem handles.

Authentication and the security model

AuthConfig selects HTTPS (token or basic) or SSH (key by path or inline PEM, optional passphrase), with optional TLS skip. Two properties are load-bearing and pinned by tests:

  • HTTPS tokens never appear in argv or the child's environment. The native backend writes the token to a 0600 temporary file consumed by a one-shot credential helper + GIT_ASKPASS, clears any host-configured helpers first (so osxkeychain/store cannot shadow the token or persist it into the user's keychain), and removes the whole directory when the operation ends.
  • SSH host-key verification is fail-closed. Setting AuthConfig.HostKeyFingerprint pins the expected key: ssh-keyscan is pre-verified in Go against the fingerprint, and only a match generates the temporary known_hosts that lets git proceed. Host resolution failure, missing keyscan, or zero fingerprint matches (possible MITM) abort the operation. Without a pin, the effective policy is accept-new: first connect trusts, and a MITM against an already-known host fails.

Cloning large repositories

CloneOptions supports partial clones (Filter, e.g. "blob:none" for on-demand blob fetch) and recursive submodule initialization — together these cut wall time and bandwidth dramatically on big monorepos.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGitNotFound       = oekiterrors.New("git binary not found")
	ErrRepoNotFound      = oekiterrors.New("repository not found")
	ErrBranchExists      = oekiterrors.New("branch already exists")
	ErrBranchNotFound    = oekiterrors.New("branch not found")
	ErrMergeConflict     = oekiterrors.New("merge conflict")
	ErrNothingToMerge    = oekiterrors.New("nothing to merge")
	ErrDirtyWorktree     = oekiterrors.New("dirty worktree")
	ErrRemoteNotFound    = oekiterrors.New("remote not found")
	ErrTagExists         = oekiterrors.New("tag already exists")
	ErrFileNotFound      = oekiterrors.New("file not found at revision")
	ErrAuthFailed        = oekiterrors.New("authentication failed")
	ErrAlreadyUpToDate   = oekiterrors.New("already up to date")
	ErrNotAGitRepo       = oekiterrors.New("not a git repository")
	ErrInvalidGitArg     = oekiterrors.New("invalid git argument")
	ErrConfigKeyNotFound = oekiterrors.New("config key not found")
	ErrStashUnsupported  = oekiterrors.New("stash requires the native git backend")
	// ErrBranchInUse 当前分支被占用(删/改它会让 HEAD 悬空 ⇒ 仓库不可用)。
	ErrBranchInUse = oekiterrors.New("branch is currently checked out")
)
View Source
var (
	// GitHTTPDialTimeout 是 TCP 连接超时。
	//
	// 没有它时,上游"地址不可达"会一直卡到操作系统的 TCP 重试超时(常见 ~2 分钟),
	// 才以 "dial tcp ... i/o timeout" 结束 —— 一次失败拖两分钟。
	GitHTTPDialTimeout = 30 * time.Second

	// GitHTTPResponseHeaderTimeout 是"已连上、等响应头"的超时。
	//
	// 覆盖另一半挂死形态:连接建立成功但服务端不回(过载/限流/中间设备吞包),
	// 此时连接一直 ESTABLISHED,既不报错也不结束。
	GitHTTPResponseHeaderTimeout = 60 * time.Second

	// GitHTTPTLSHandshakeTimeout 是 TLS 握手超时。
	GitHTTPTLSHandshakeTimeout = 15 * time.Second
)

Git 传输的默认超时。可按需调整(进程级)。

Functions

func IsAuthFailed

func IsAuthFailed(err error) bool

IsAuthFailed checks if an error is an authentication error.

func IsMergeConflict

func IsMergeConflict(err error) bool

IsMergeConflict checks if an error is a merge conflict.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a not-found error. oekiterrors.In walks the chain once for all four sentinels instead of four separate walks.

func Register

func Register(name string, ctor GitBackendConstructor)

Register registers a GitBackend constructor.

func TransportAuth added in v0.72.0

func TransportAuth(auth AuthConfig) (transport.AuthMethod, error)

TransportAuth maps AuthConfig onto a go-git transport.AuthMethod for callers that drive go-git directly (e.g. a mirror pipeline that needs to list remote tags or fetch by refspec) instead of going through a GitBackend. It is package-level and stateless: the mapping depends only on the AuthConfig.

AuthNone (and the empty Type) maps to a nil AuthMethod — anonymous access — which is what go-git expects for "no credentials".

Types

type AdvancedOps

type AdvancedOps interface {
	// RevParse resolves a revision (ref/short-SHA/etc.) to a full SHA.
	RevParse(ctx context.Context, repoPath string, ref string) (string, error)
	// MergeBase returns the best common ancestor of two commits.
	MergeBase(ctx context.Context, repoPath string, a string, b string) (string, error)
	// DiffNames returns the names of files changed between two commits.
	DiffNames(ctx context.Context, repoPath string, from string, to string) ([]string, error)
	// DeletedFiles returns files deleted between two commits.
	DeletedFiles(ctx context.Context, repoPath string, from string, to string) ([]string, error)
	// CheckoutRef checks out ref: branch names attach HEAD to the branch
	// (matching `git checkout <branch>`), anything else detaches.
	CheckoutRef(ctx context.Context, repoPath string, ref string) error
	// CheckoutDetached force-checks out ref in detached HEAD state, even
	// when ref names a branch — pins HEAD to the commit.
	CheckoutDetached(ctx context.Context, repoPath string, ref string) error
	// CheckoutFiles restores the given files from ref into the working tree.
	CheckoutFiles(ctx context.Context, repoPath string, ref string, files []string) error
	// Add stages the given files into the index.
	Add(ctx context.Context, repoPath string, files []string) error
	// CommitWithIdentity creates a commit using an explicit author identity.
	CommitWithIdentity(ctx context.Context, repoPath string, name string, email string, message string) error
}

AdvancedOps covers lower-level revision, index, and identity operations.

type AuthConfig

type AuthConfig struct {
	// Type selects the authentication method. AuthNone performs no auth.
	Type AuthType

	// Username is the HTTP Basic username (ignored for SSH).
	Username string
	// Password is the HTTP Basic password (used together with Username).
	Password string
	// Token is the HTTPS access token (used by AuthHTTPToken).
	Token string

	// SSHKey is the on-disk path to an SSH private key.
	SSHKey string

	// SSHKeyContent holds the raw PEM content of an SSH private key.
	// When set (and SSHKey is empty), a temporary key file is created
	// automatically for the git operation. This is useful for keys stored
	// in a database rather than on disk.
	SSHKeyContent string

	// Passphrase is the passphrase for decrypting the SSH private key.
	// Used together with SSHKey or SSHKeyContent.
	Passphrase string

	// InsecureSkipTLS disables TLS certificate verification for HTTPS
	// operations (equivalent to http.sslVerify=false). For SSH it also
	// disables host-key verification (explicit opt-out).
	// Carried on AuthConfig so every network operation that
	// takes auth (Fetch, Push, Clone, Pull, FetchAll, PushTag,
	// TestConnection, ...) honors it uniformly.
	InsecureSkipTLS bool

	// KnownHostsPath 指定 known_hosts 文件(空=用 ~/.ssh/known_hosts)。
	// 平台级独立 known_hosts 时使用,避免全局信任面过大。
	KnownHostsPath string

	// HostKeyFingerprint 期望的主机公钥指纹("SHA256:xxx" 或裸 base64)。
	// 设置后:连接时校验服务器公钥指纹必须一致,否则拒绝(防 MITM)。
	// 优先级高于 known_hosts 文件匹配。
	HostKeyFingerprint string
}

AuthConfig holds authentication credentials for git operations. Build one with the New*Auth helpers in auth.go when possible.

func NewHTTPBasicAuth

func NewHTTPBasicAuth(username, password string) AuthConfig

NewHTTPBasicAuth builds an AuthConfig for HTTP Basic authentication.

func NewSSHKeyContentAuth

func NewSSHKeyContentAuth(keyContent, passphrase string) AuthConfig

NewSSHKeyContentAuth builds an AuthConfig for SSH authentication using in-memory key content (e.g. from a database). The backend will create a temporary file automatically if needed.

func NewSSHKeyFileAuth

func NewSSHKeyFileAuth(keyPath, passphrase string) AuthConfig

NewSSHKeyFileAuth builds an AuthConfig for SSH authentication using a key file on disk.

func NewTokenAuth

func NewTokenAuth(token string) AuthConfig

NewTokenAuth builds an AuthConfig for HTTPS token authentication.

When authenticating against git hosting platforms (GitHub, GitLab, Gitea, etc.) over HTTPS the credentials are exchanged via HTTP Basic Auth: the username is an arbitrary non-empty placeholder and the real token is sent as the password. An empty token collapses to AuthNone so callers can simply pass through an optional token without extra branching.

type AuthType

type AuthType string

AuthType represents the authentication method used for a git operation.

const (
	// AuthNone disables authentication (public repositories, local repos).
	AuthNone AuthType = "none"
	// AuthHTTPBasic authenticates over HTTPS using HTTP Basic. The username is
	// an arbitrary placeholder and the secret is carried in Password.
	AuthHTTPBasic AuthType = "http_basic"
	// AuthHTTPToken authenticates over HTTPS using a bearer/token sent as the
	// password of HTTP Basic auth (the convention used by most git hosts).
	AuthHTTPToken AuthType = "http_token"
	// AuthSSH authenticates over the SSH protocol using a private key.
	AuthSSH AuthType = "ssh"
)

type BlobContent

type BlobContent struct {
	// Content is the file payload. When IsBinary it is base64-encoded.
	Content string
	// Encoding is either EncodingUTF8 or EncodingBase64.
	Encoding BlobEncoding
	// Size is the decoded payload size in bytes.
	Size int64
	// IsBinary is true when the blob is detected as binary.
	IsBinary bool
}

BlobContent represents the content of a file at a given revision.

type BlobEncoding

type BlobEncoding string

BlobEncoding is the encoding used for BlobContent.Content.

const (
	EncodingUTF8   BlobEncoding = "utf-8"
	EncodingBase64 BlobEncoding = "base64"
)

type BranchDetail

type BranchDetail struct {
	Name string
	Hash string
	// IsCurrent is true when this is the checked-out branch.
	IsCurrent bool
	// IsRemote is true for remote-tracking branches (refs/remotes/*).
	IsRemote bool
	// Remote is the remote name for remote branches (e.g. "origin").
	Remote string
	// Upstream is the configured upstream tracking branch (e.g. "origin/main").
	Upstream string
	Author   string
	Email    string
	// Date is the tip commit's author date formatted as RFC3339.
	Date string
	// Message is the subject line of the tip commit.
	Message string
}

BranchDetail represents a branch with extended information.

type BranchOps

type BranchOps interface {
	// ListRemoteBranches lists branches that exist on the given remote.
	ListRemoteBranches(ctx context.Context, repoPath string, remote string) ([]string, error)
	// ListLocalBranches lists local branches (refs/heads/*).
	ListLocalBranches(ctx context.Context, repoPath string) ([]string, error)
	// ListBranches lists both local and remote branches with extended details.
	ListBranches(ctx context.Context, repoPath string) ([]BranchDetail, error)
	// CreateBranch creates a branch pointing at ref (or HEAD when empty).
	CreateBranch(ctx context.Context, repoPath string, branch string, ref string) error
	// DeleteBranch deletes a local branch.
	DeleteBranch(ctx context.Context, repoPath string, branch string) error
	// RenameBranch renames a local branch.
	RenameBranch(ctx context.Context, repoPath string, oldName string, newName string) error
	// Checkout switches the working tree to the given branch.
	Checkout(ctx context.Context, repoPath string, branch string) error
	// GetCurrentBranch returns the name of the checked-out branch.
	GetCurrentBranch(ctx context.Context, repoPath string) (string, error)
	// GetBranchSyncInfo returns how many commits branch is ahead/behind upstream.
	GetBranchSyncInfo(ctx context.Context, repoPath string, branch string, upstream string) (ahead int, behind int, err error)
}

BranchOps covers branch listing, creation, deletion, and checkout.

type CloneOptions

type CloneOptions struct {
	// URL is the remote URL (HTTPS or SSH) to clone from.
	URL string
	// Path is the destination directory for the new working tree.
	Path string
	// Branch checks out the given branch after clone (optional).
	Branch string
	// Depth creates a shallow clone with the given history depth.
	// Zero means a full clone.
	Depth int
	Auth  AuthConfig
	// Progress receives human-readable progress output (optional).
	Progress        io.Writer
	NoCheckout      bool
	SingleBranch    bool
	InsecureSkipTLS bool
	// Filter 部分克隆:"blob:none" / "tree:0" 等;空=全量
	Filter string
	// Submodules clone 后递归初始化子模块
	Submodules bool
}

CloneOptions contains options for cloning a repository.

type CommitInfo

type CommitInfo struct {
	// Hash is the full 40-character commit SHA.
	Hash string
	// Message is the commit message.
	Message string
	// Author is the commit author's name.
	Author string
	// Date is the author date formatted as RFC3339.
	Date string
}

CommitInfo represents a git commit.

type CommitOps

type CommitOps interface {
	// GetCommitsBetween returns commits in the range (from, to].
	GetCommitsBetween(ctx context.Context, repoPath string, from string, to string) ([]CommitInfo, error)
	// IsAncestor reports whether ancestor is an ancestor of descendant.
	IsAncestor(ctx context.Context, repoPath string, ancestor string, descendant string) (bool, error)
	// Merge merges branch into the current HEAD according to opts.
	Merge(ctx context.Context, repoPath string, branch string, opts MergeOptions) error
	// CherryPick applies the changes of commitHash onto the current HEAD.
	CherryPick(ctx context.Context, repoPath string, commitHash string) error
	// Rebase rebases the current branch onto onto.
	Rebase(ctx context.Context, repoPath string, onto string) error
	// RebaseAbort aborts an in-progress rebase.
	RebaseAbort(ctx context.Context, repoPath string) error
	// RebaseContinue continues an in-progress rebase after resolving conflicts.
	RebaseContinue(ctx context.Context, repoPath string) error
}

CommitOps covers history traversal and history-rewriting operations.

type ConfigOps

type ConfigOps interface {
	// GetConfig reads a config value by dotted key (e.g. "user.name").
	GetConfig(ctx context.Context, repoPath string, key string) (string, error)
	// SetConfig sets a config value by dotted key (e.g. "user.email").
	SetConfig(ctx context.Context, repoPath string, key string, value string) error
}

ConfigOps covers reading and writing git config values.

type CoreOps

type CoreOps interface {
	// Fetch downloads objects and refs from a remote into the local repository
	// without touching the working tree.
	Fetch(ctx context.Context, opts FetchOptions) (*FetchResult, error)
	// FetchAll fetches tags and every branch from all configured remotes.
	FetchAll(ctx context.Context, repoPath string, auth AuthConfig) error
	// Push uploads local refs to a remote.
	Push(ctx context.Context, opts PushOptions) (*PushResult, error)
	// Pull fetches from and integrates with the current branch (fetch + merge).
	Pull(ctx context.Context, repoPath string, remote string, branch string, auth AuthConfig) error
	// Clone clones a remote repository into a new local working tree.
	Clone(ctx context.Context, opts CloneOptions) error
	// Init creates a new empty git repository at repoPath.
	Init(ctx context.Context, repoPath string) error
	// RunRaw executes an arbitrary git command and returns its combined output.
	// Only supported by the native backend.
	RunRaw(ctx context.Context, repoPath string, args []string) (stdout string, stderr string, err error)
}

CoreOps covers repository-level network and lifecycle operations.

type DiffOptions

type DiffOptions struct {
	// From is the starting commit SHA. When both From and To are empty the
	// diff is computed between the working tree and HEAD.
	From string
	// To is the ending commit SHA.
	To string
	// Paths restricts the diff to the given paths (optional).
	Paths []string
}

DiffOptions contains options for getting a diff.

type FetchOptions

type FetchOptions struct {
	// RepoPath is the local working tree to operate on.
	RepoPath string
	// Remote is the remote name to fetch from. Defaults to "origin" when
	// empty.
	Remote string
	// Branches limits the fetch to the given branch/ref names. When empty all
	// branches are fetched. Full 40-char SHAs are ignored as they are not
	// valid fetch refspecs.
	Branches []string
	// Tags fetches all tags when true.
	Tags bool
	// Prune removes remote-tracking refs that no longer exist on the remote.
	// Note: the native backend always passes --prune so that deleted branches
	// actually surface in FetchResult.DeletedBranch; the gogit backend prunes
	// only when this flag is set.
	Prune bool
	// Depth limits the fetch to the given number of commits (shallow fetch).
	// Zero means no depth limit.
	Depth           int
	InsecureSkipTLS bool
	Auth            AuthConfig
	// Progress receives human-readable progress output (optional).
	Progress io.Writer
}

FetchOptions contains options for fetching from a remote.

type FetchResult

type FetchResult struct {
	FetchedRefs   []string
	NewBranches   []string
	UpdatedBranch []string
	DeletedBranch []string
	NewTags       []string
}

FetchResult contains the result of a fetch operation.

Both backends populate every field the same way, from a before/after diff of the remote-tracking refs and tags:

  • FetchedRefs: full refnames (refs/remotes/<remote>/..., refs/tags/...) of every ref the fetch created or moved;
  • NewBranches/UpdatedBranch/DeletedBranch: short branch names (after the refs/remotes/<remote>/ prefix);
  • NewTags: short tag names (after the refs/tags/ prefix).

type FileOps

type FileOps interface {
	// GetFileAtRevision returns the raw bytes of path at the given ref.
	GetFileAtRevision(ctx context.Context, repoPath string, path string, ref string) ([]byte, error)
	// GetFileHistory returns commits that touched path (most recent first),
	// limited to limit entries (0 means all).
	GetFileHistory(ctx context.Context, repoPath string, path string, limit int) ([]CommitInfo, error)
	// GetTree lists entries under dirPath at ref. When recursive is true it
	// lists all files (not directories) below dirPath.
	GetTree(ctx context.Context, repoPath string, ref string, dirPath string, recursive bool) ([]TreeEntry, error)
	// GetBlob returns the content of filePath at ref.
	GetBlob(ctx context.Context, repoPath string, ref string, filePath string) (*BlobContent, error)
	// GetCommit returns metadata for a single commit.
	GetCommit(ctx context.Context, repoPath string, hash string) (*CommitInfo, error)
}

FileOps covers reading files, trees, and blobs at arbitrary revisions.

type FileStatus

type FileStatus struct {
	Path string
	// Worktree is the status of the file in the working tree.
	Worktree StatusCode
	// Staging is the status of the file in the staging area (index).
	Staging StatusCode
}

FileStatus represents the status of a single file.

type GitBackend

GitBackend is the interface for low-level, local git operations.

Every method takes a context (for cancellation/timeouts) and the absolute path of a working tree. Commit/ref arguments are full 40-character SHAs unless stated otherwise; dates are RFC3339 formatted strings. Methods return wrapped errors created by newGitError (see errors.go); use the IsNotFound / IsMergeConflict helpers to classify them.

GitBackend composes the focused sub-interfaces defined in iface.go (CoreOps, BranchOps, StatusDiffOps, CommitOps, RemoteOps, TagOps, FileOps, StashOps, ConfigOps, AdvancedOps). Consumers that only need a subset of capabilities may depend on the narrower sub-interface directly.

func NewGitBackend

func NewGitBackend(opts Options) (GitBackend, error)

NewGitBackend creates a GitBackend using the registry. If opts.Type is empty, it auto-detects (native first, fallback to gogit).

type GitBackendConstructor

type GitBackendConstructor func(opts Options) (GitBackend, error)

GitBackendConstructor creates a GitBackend instance.

type GitError

type GitError struct {
	Op      string // operation name, e.g., "Fetch"
	Path    string // repo path
	Command string // git command that failed
	Stderr  string // stderr output
	Err     error  // underlying error
}

GitError is a structured error from a git operation.

func (*GitError) Error

func (e *GitError) Error() string

func (*GitError) Is

func (e *GitError) Is(target error) bool

func (*GitError) Unwrap

func (e *GitError) Unwrap() error

type GoGitBackend

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

func NewGoGitBackend

func NewGoGitBackend(opts Options) *GoGitBackend

func (*GoGitBackend) Add

func (b *GoGitBackend) Add(ctx context.Context, repoPath string, files []string) error

func (*GoGitBackend) AddRemote

func (b *GoGitBackend) AddRemote(ctx context.Context, repoPath, name, url string) error

func (*GoGitBackend) Checkout

func (b *GoGitBackend) Checkout(ctx context.Context, repoPath, branch string) error

func (*GoGitBackend) CheckoutDetached

func (b *GoGitBackend) CheckoutDetached(ctx context.Context, repoPath, ref string) error

CheckoutDetached force-checks out ref in detached HEAD state, even when the ref names a branch. Use it when the caller explicitly wants to pin HEAD to a commit rather than follow a branch (CheckoutRef attaches for branches).

func (*GoGitBackend) CheckoutFiles

func (b *GoGitBackend) CheckoutFiles(ctx context.Context, repoPath, ref string, files []string) error

func (*GoGitBackend) CheckoutRef

func (b *GoGitBackend) CheckoutRef(ctx context.Context, repoPath, ref string) error

CheckoutRef force-checks out ref. A ref that names a local branch (bare name or refs/heads/... form) is checked out ATTACHED — HEAD follows the branch, matching the native backend and `git checkout <branch>`. Anything else that resolves to a bare commit (raw hash, tag, HEAD~n) is checked out detached. CheckoutRef used to detach unconditionally, silently drifting from the native backend's attached semantics for branch names.

func (*GoGitBackend) CherryPick

func (b *GoGitBackend) CherryPick(ctx context.Context, repoPath, commitHash string) error

func (*GoGitBackend) Clone

func (b *GoGitBackend) Clone(ctx context.Context, opts CloneOptions) error

func (*GoGitBackend) CommitWithIdentity

func (b *GoGitBackend) CommitWithIdentity(ctx context.Context, repoPath, name, email, message string) error

func (*GoGitBackend) CreateBranch

func (b *GoGitBackend) CreateBranch(ctx context.Context, repoPath, branch, ref string) error

func (*GoGitBackend) CreateTag

func (b *GoGitBackend) CreateTag(ctx context.Context, repoPath, name, ref string) error

func (*GoGitBackend) DeleteBranch

func (b *GoGitBackend) DeleteBranch(ctx context.Context, repoPath, branch string) error

func (*GoGitBackend) DeleteTag

func (b *GoGitBackend) DeleteTag(ctx context.Context, repoPath, name string) error

func (*GoGitBackend) DeletedFiles

func (b *GoGitBackend) DeletedFiles(ctx context.Context, repoPath, from, to string) ([]string, error)

func (*GoGitBackend) Diff

func (b *GoGitBackend) Diff(ctx context.Context, repoPath string, opts DiffOptions) (string, error)

func (*GoGitBackend) DiffNames

func (b *GoGitBackend) DiffNames(ctx context.Context, repoPath, from, to string) ([]string, error)

func (*GoGitBackend) Fetch

func (b *GoGitBackend) Fetch(ctx context.Context, opts FetchOptions) (*FetchResult, error)

func (*GoGitBackend) FetchAll

func (b *GoGitBackend) FetchAll(ctx context.Context, repoPath string, auth AuthConfig) error

func (*GoGitBackend) GetBlob

func (b *GoGitBackend) GetBlob(ctx context.Context, repoPath, ref, filePath string) (*BlobContent, error)

func (*GoGitBackend) GetBranchSyncInfo

func (b *GoGitBackend) GetBranchSyncInfo(ctx context.Context, repoPath, branch, upstream string) (int, int, error)

func (*GoGitBackend) GetCommit

func (b *GoGitBackend) GetCommit(ctx context.Context, repoPath, hashStr string) (*CommitInfo, error)

func (*GoGitBackend) GetCommitsBetween

func (b *GoGitBackend) GetCommitsBetween(ctx context.Context, repoPath, from, to string) ([]CommitInfo, error)

func (*GoGitBackend) GetConfig

func (b *GoGitBackend) GetConfig(ctx context.Context, repoPath, key string) (string, error)

GetConfig reads any git config value. Supports both simple keys (e.g. "core.bare") and subsection keys (e.g. "remote.origin.url"). The special keys "user.name" and "user.email" are handled via the high-level Author struct for backward compatibility. A missing key fails with an error wrapping ErrConfigKeyNotFound; a key explicitly set to the empty string returns ("", nil) — the two are distinguishable.

func (*GoGitBackend) GetCurrentBranch

func (b *GoGitBackend) GetCurrentBranch(ctx context.Context, repoPath string) (string, error)

func (*GoGitBackend) GetFileAtRevision

func (b *GoGitBackend) GetFileAtRevision(ctx context.Context, repoPath, path, ref string) ([]byte, error)

func (*GoGitBackend) GetFileHistory

func (b *GoGitBackend) GetFileHistory(ctx context.Context, repoPath, path string, limit int) ([]CommitInfo, error)

func (*GoGitBackend) GetRemoteURL

func (b *GoGitBackend) GetRemoteURL(ctx context.Context, repoPath, name string) (string, error)

func (*GoGitBackend) GetRemotes

func (b *GoGitBackend) GetRemotes(ctx context.Context, repoPath string) ([]string, error)

func (*GoGitBackend) GetStatus

func (b *GoGitBackend) GetStatus(ctx context.Context, repoPath string) (*RepoStatus, error)

func (*GoGitBackend) GetTagList

func (b *GoGitBackend) GetTagList(ctx context.Context, repoPath string) ([]TagInfo, error)

func (*GoGitBackend) GetTree

func (b *GoGitBackend) GetTree(ctx context.Context, repoPath, ref, dirPath string, recursive bool) ([]TreeEntry, error)

func (*GoGitBackend) Init

func (b *GoGitBackend) Init(ctx context.Context, repoPath string) error

func (*GoGitBackend) IsAncestor

func (b *GoGitBackend) IsAncestor(ctx context.Context, repoPath, ancestor, descendant string) (bool, error)

func (*GoGitBackend) ListBranches

func (b *GoGitBackend) ListBranches(ctx context.Context, repoPath string) ([]BranchDetail, error)

func (*GoGitBackend) ListLocalBranches

func (b *GoGitBackend) ListLocalBranches(ctx context.Context, repoPath string) ([]string, error)

func (*GoGitBackend) ListRemoteBranches

func (b *GoGitBackend) ListRemoteBranches(ctx context.Context, repoPath, remote string) ([]string, error)

func (*GoGitBackend) Merge

func (b *GoGitBackend) Merge(ctx context.Context, repoPath, branch string, opts MergeOptions) error

func (*GoGitBackend) MergeBase

func (b *GoGitBackend) MergeBase(ctx context.Context, repoPath, a, other string) (string, error)

func (*GoGitBackend) Pull

func (b *GoGitBackend) Pull(ctx context.Context, repoPath, remote, branch string, auth AuthConfig) error

func (*GoGitBackend) Push

func (b *GoGitBackend) Push(ctx context.Context, opts PushOptions) (*PushResult, error)

func (*GoGitBackend) PushTag

func (b *GoGitBackend) PushTag(ctx context.Context, repoPath, remote, name string, auth AuthConfig) error

func (*GoGitBackend) Rebase

func (b *GoGitBackend) Rebase(ctx context.Context, repoPath, onto string) error

func (*GoGitBackend) RebaseAbort

func (b *GoGitBackend) RebaseAbort(ctx context.Context, repoPath string) error

func (*GoGitBackend) RebaseContinue

func (b *GoGitBackend) RebaseContinue(ctx context.Context, repoPath string) error

func (*GoGitBackend) RemoveRemote

func (b *GoGitBackend) RemoveRemote(ctx context.Context, repoPath, name string) error

func (*GoGitBackend) RenameBranch

func (b *GoGitBackend) RenameBranch(ctx context.Context, repoPath, oldName, newName string) error

func (*GoGitBackend) RevParse

func (b *GoGitBackend) RevParse(ctx context.Context, repoPath, ref string) (string, error)

func (*GoGitBackend) RunRaw

func (b *GoGitBackend) RunRaw(ctx context.Context, repoPath string, args []string) (string, string, error)

RunRaw is not supported by the pure-Go (gogit) backend because go-git does not shell out to the git binary. This method exists to satisfy the GitBackend interface; callers that need arbitrary git commands should use the native backend instead.

func (*GoGitBackend) SetConfig

func (b *GoGitBackend) SetConfig(ctx context.Context, repoPath, key, value string) error

SetConfig writes any git config value. Supports both simple keys and subsection keys, matching the same format as GetConfig. The special keys "user.name" and "user.email" are written via the high-level Author struct.

func (*GoGitBackend) StashApply

func (b *GoGitBackend) StashApply(ctx context.Context, repoPath string, stashIdx int) error

func (*GoGitBackend) StashClear

func (b *GoGitBackend) StashClear(ctx context.Context, repoPath string) error

func (*GoGitBackend) StashDrop

func (b *GoGitBackend) StashDrop(ctx context.Context, repoPath string, stashIdx int) error

func (*GoGitBackend) StashList

func (b *GoGitBackend) StashList(ctx context.Context, repoPath string) ([]StashEntry, error)

func (*GoGitBackend) StashPop

func (b *GoGitBackend) StashPop(ctx context.Context, repoPath string, stashIdx int) error

func (*GoGitBackend) StashSave

func (b *GoGitBackend) StashSave(ctx context.Context, repoPath, message string) error

func (*GoGitBackend) TestConnection

func (b *GoGitBackend) TestConnection(ctx context.Context, url string, auth AuthConfig) error

type Logger

type Logger interface {
	Debug(msg string, kv ...any)
	Info(msg string, kv ...any)
	Warn(msg string, kv ...any)
	Error(msg string, kv ...any)
}

Logger is the minimal logging surface the gitbackend needs, declared consumer-side (Go idiom: the consumer owns the interface) so this low-level local-git package does not depend on the forge-abstraction provider package. provider.Logger satisfies it structurally, so callers can inject the same logger implementation for both.

func NewNoopLogger

func NewNoopLogger() Logger

NewNoopLogger returns a Logger that discards all output.

type MergeOptions

type MergeOptions struct {
	// Message overrides the auto-generated merge commit message.
	Message string
	// Squash merges the branch as a single squashed change without
	// recording merge ancestry.
	Squash bool
	// NoCommit performs the merge but leaves the result staged without
	// committing.
	NoCommit bool
	// FFOnly only allows a fast-forward merge; aborts otherwise.
	FFOnly bool
	// AllowUnrelated permits merging histories with no common ancestor.
	AllowUnrelated bool
}

MergeOptions contains options for merging a branch into HEAD.

type NativeGitBackend

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

func NewNativeGitBackend

func NewNativeGitBackend(opts Options) (*NativeGitBackend, error)

func (*NativeGitBackend) Add

func (b *NativeGitBackend) Add(ctx context.Context, repoPath string, files []string) error

func (*NativeGitBackend) AddRemote

func (b *NativeGitBackend) AddRemote(ctx context.Context, repoPath, name, url string) error

func (*NativeGitBackend) Checkout

func (b *NativeGitBackend) Checkout(ctx context.Context, repoPath, branch string) error

func (*NativeGitBackend) CheckoutDetached added in v0.77.0

func (b *NativeGitBackend) CheckoutDetached(ctx context.Context, repoPath, ref string) error

CheckoutDetached implements BranchOps: `git checkout --detach --force` pins HEAD to ref's commit even when ref names a branch.

func (*NativeGitBackend) CheckoutFiles

func (b *NativeGitBackend) CheckoutFiles(ctx context.Context, repoPath, ref string, files []string) error

func (*NativeGitBackend) CheckoutRef

func (b *NativeGitBackend) CheckoutRef(ctx context.Context, repoPath, ref string) error

func (*NativeGitBackend) CherryPick

func (b *NativeGitBackend) CherryPick(ctx context.Context, repoPath, commitHash string) error

func (*NativeGitBackend) Clone

func (b *NativeGitBackend) Clone(ctx context.Context, opts CloneOptions) error

func (*NativeGitBackend) CommitWithIdentity

func (b *NativeGitBackend) CommitWithIdentity(ctx context.Context, repoPath, name, email, message string) error

func (*NativeGitBackend) CreateBranch

func (b *NativeGitBackend) CreateBranch(ctx context.Context, repoPath, branch, ref string) error

func (*NativeGitBackend) CreateTag

func (b *NativeGitBackend) CreateTag(ctx context.Context, repoPath, name, ref string) error

func (*NativeGitBackend) DeleteBranch

func (b *NativeGitBackend) DeleteBranch(ctx context.Context, repoPath, branch string) error

func (*NativeGitBackend) DeleteTag

func (b *NativeGitBackend) DeleteTag(ctx context.Context, repoPath, name string) error

func (*NativeGitBackend) DeletedFiles

func (b *NativeGitBackend) DeletedFiles(ctx context.Context, repoPath, from, to string) ([]string, error)

func (*NativeGitBackend) Diff

func (b *NativeGitBackend) Diff(ctx context.Context, repoPath string, opts DiffOptions) (string, error)

func (*NativeGitBackend) DiffNames

func (b *NativeGitBackend) DiffNames(ctx context.Context, repoPath, from, to string) ([]string, error)

func (*NativeGitBackend) Fetch

func (*NativeGitBackend) FetchAll

func (b *NativeGitBackend) FetchAll(ctx context.Context, repoPath string, auth AuthConfig) error

func (*NativeGitBackend) GetBlob

func (b *NativeGitBackend) GetBlob(ctx context.Context, repoPath, ref, filePath string) (*BlobContent, error)

func (*NativeGitBackend) GetBranchSyncInfo

func (b *NativeGitBackend) GetBranchSyncInfo(ctx context.Context, repoPath, branch, upstream string) (int, int, error)

func (*NativeGitBackend) GetCommit

func (b *NativeGitBackend) GetCommit(ctx context.Context, repoPath, hashStr string) (*CommitInfo, error)

func (*NativeGitBackend) GetCommitsBetween

func (b *NativeGitBackend) GetCommitsBetween(ctx context.Context, repoPath, from, to string) ([]CommitInfo, error)

func (*NativeGitBackend) GetConfig

func (b *NativeGitBackend) GetConfig(ctx context.Context, repoPath, key string) (string, error)

func (*NativeGitBackend) GetCurrentBranch

func (b *NativeGitBackend) GetCurrentBranch(ctx context.Context, repoPath string) (string, error)

func (*NativeGitBackend) GetFileAtRevision

func (b *NativeGitBackend) GetFileAtRevision(ctx context.Context, repoPath, path, ref string) ([]byte, error)

func (*NativeGitBackend) GetFileHistory

func (b *NativeGitBackend) GetFileHistory(ctx context.Context, repoPath, path string, limit int) ([]CommitInfo, error)

func (*NativeGitBackend) GetRemoteURL

func (b *NativeGitBackend) GetRemoteURL(ctx context.Context, repoPath, name string) (string, error)

func (*NativeGitBackend) GetRemotes

func (b *NativeGitBackend) GetRemotes(ctx context.Context, repoPath string) ([]string, error)

func (*NativeGitBackend) GetStatus

func (b *NativeGitBackend) GetStatus(ctx context.Context, repoPath string) (*RepoStatus, error)

func (*NativeGitBackend) GetTagList

func (b *NativeGitBackend) GetTagList(ctx context.Context, repoPath string) ([]TagInfo, error)

func (*NativeGitBackend) GetTree

func (b *NativeGitBackend) GetTree(ctx context.Context, repoPath, ref, dirPath string, recursive bool) ([]TreeEntry, error)

func (*NativeGitBackend) Init

func (b *NativeGitBackend) Init(ctx context.Context, repoPath string) error

func (*NativeGitBackend) IsAncestor

func (b *NativeGitBackend) IsAncestor(ctx context.Context, repoPath, ancestor, descendant string) (bool, error)

func (*NativeGitBackend) ListBranches

func (b *NativeGitBackend) ListBranches(ctx context.Context, repoPath string) ([]BranchDetail, error)

func (*NativeGitBackend) ListLocalBranches

func (b *NativeGitBackend) ListLocalBranches(ctx context.Context, repoPath string) ([]string, error)

func (*NativeGitBackend) ListRemoteBranches

func (b *NativeGitBackend) ListRemoteBranches(ctx context.Context, repoPath, remote string) ([]string, error)

func (*NativeGitBackend) Merge

func (b *NativeGitBackend) Merge(ctx context.Context, repoPath, branch string, opts MergeOptions) error

func (*NativeGitBackend) MergeBase

func (b *NativeGitBackend) MergeBase(ctx context.Context, repoPath, a, other string) (string, error)

func (*NativeGitBackend) Pull

func (b *NativeGitBackend) Pull(ctx context.Context, repoPath, remote, branch string, auth AuthConfig) error

func (*NativeGitBackend) Push

func (*NativeGitBackend) PushTag

func (b *NativeGitBackend) PushTag(ctx context.Context, repoPath, remote, name string, auth AuthConfig) error

func (*NativeGitBackend) Rebase

func (b *NativeGitBackend) Rebase(ctx context.Context, repoPath, onto string) error

func (*NativeGitBackend) RebaseAbort

func (b *NativeGitBackend) RebaseAbort(ctx context.Context, repoPath string) error

func (*NativeGitBackend) RebaseContinue

func (b *NativeGitBackend) RebaseContinue(ctx context.Context, repoPath string) error

func (*NativeGitBackend) RemoveRemote

func (b *NativeGitBackend) RemoveRemote(ctx context.Context, repoPath, name string) error

func (*NativeGitBackend) RenameBranch

func (b *NativeGitBackend) RenameBranch(ctx context.Context, repoPath, oldName, newName string) error

func (*NativeGitBackend) RevParse

func (b *NativeGitBackend) RevParse(ctx context.Context, repoPath, ref string) (string, error)

func (*NativeGitBackend) RunRaw

func (b *NativeGitBackend) RunRaw(ctx context.Context, repoPath string, args []string) (string, string, error)

func (*NativeGitBackend) SetConfig

func (b *NativeGitBackend) SetConfig(ctx context.Context, repoPath, key, value string) error

func (*NativeGitBackend) StashApply

func (b *NativeGitBackend) StashApply(ctx context.Context, repoPath string, index int) error

func (*NativeGitBackend) StashClear

func (b *NativeGitBackend) StashClear(ctx context.Context, repoPath string) error

func (*NativeGitBackend) StashDrop

func (b *NativeGitBackend) StashDrop(ctx context.Context, repoPath string, index int) error

func (*NativeGitBackend) StashList

func (b *NativeGitBackend) StashList(ctx context.Context, repoPath string) ([]StashEntry, error)

func (*NativeGitBackend) StashPop

func (b *NativeGitBackend) StashPop(ctx context.Context, repoPath string, index int) error

func (*NativeGitBackend) StashSave

func (b *NativeGitBackend) StashSave(ctx context.Context, repoPath, message string) error

func (*NativeGitBackend) TestConnection

func (b *NativeGitBackend) TestConnection(ctx context.Context, url string, auth AuthConfig) error

type Options

type Options struct {
	Type   string // "native", "gogit", or "" for auto-detect
	Logger Logger
}

Options holds configuration for creating a GitBackend.

type PushOptions

type PushOptions struct {
	RepoPath string
	// Remote is the remote name to push to (e.g. "origin").
	Remote string
	// RefSpecs are the refs to push (e.g. "refs/heads/main:refs/heads/main").
	// Ignored when Mirror is true.
	RefSpecs []string
	// Force forces the push (overwrites remote refs).
	Force bool
	// Mirror pushes all refs as a mirror (--mirror).
	Mirror          bool
	InsecureSkipTLS bool
	Auth            AuthConfig
	// Progress receives human-readable progress output (optional).
	Progress io.Writer
}

PushOptions contains options for pushing to a remote.

type PushResult

type PushResult struct {
	// PushedRefs are the refs that were pushed.
	PushedRefs []string
	// Errors collects per-ref errors reported by the remote (if any).
	Errors []string
}

PushResult contains the result of a push operation.

type RemoteOps

type RemoteOps interface {
	// GetRemotes returns the names of all configured remotes.
	GetRemotes(ctx context.Context, repoPath string) ([]string, error)
	// AddRemote adds a new remote.
	AddRemote(ctx context.Context, repoPath string, name string, url string) error
	// RemoveRemote removes a configured remote.
	RemoveRemote(ctx context.Context, repoPath string, name string) error
	// GetRemoteURL returns the URL of a named remote.
	GetRemoteURL(ctx context.Context, repoPath string, name string) (string, error)
	// TestConnection verifies that url is reachable with the given credentials.
	TestConnection(ctx context.Context, url string, auth AuthConfig) error
}

RemoteOps covers remote configuration and connectivity checks.

type RepoStatus

type RepoStatus struct {
	// Branch is the name of the current branch (without the refs/heads/ prefix).
	Branch string
	// IsClean is true when there are no staged, unstaged or untracked changes.
	IsClean bool
	// Staged lists files with changes staged for commit.
	Staged []FileStatus
	// Unstaged lists files with changes in the working tree (not yet staged).
	Unstaged []FileStatus
	// Untracked lists untracked files (not ignored).
	Untracked []string
	// Ahead is the number of local commits not pushed to upstream.
	Ahead int
	// Behind is the number of upstream commits not pulled locally.
	Behind int
}

RepoStatus represents the working tree status.

type Repository

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

Repository is a stateful convenience wrapper around GitBackend that binds a repository path together with its authentication and TLS settings. It removes the need for callers to repeat repoPath/auth/insecure on every operation.

Create instances with CloneRepository (clones a remote first) or OpenRepository (operates on an already-present working tree).

func CloneRepository

func CloneRepository(ctx context.Context, b GitBackend, url, path string, auth AuthConfig, insecure bool) (*Repository, error)

CloneRepository clones url into path and returns a Repository bound to it.

func OpenRepository

func OpenRepository(b GitBackend, dir string, auth AuthConfig, insecure bool) *Repository

OpenRepository wraps an existing working tree located at dir with the given auth and TLS settings. The backend must already be created by the caller.

func (*Repository) Auth

func (r *Repository) Auth() AuthConfig

Auth returns the bound authentication configuration.

func (*Repository) Checkout

func (r *Repository) Checkout(ctx context.Context, ref string) error

Checkout checks out the given ref (branch, tag or commit).

func (*Repository) CheckoutDetached

func (r *Repository) CheckoutDetached(ctx context.Context, ref string) error

CheckoutDetached force-checks out the given ref in detached HEAD state, even when ref names a branch.

func (*Repository) CheckoutFiles

func (r *Repository) CheckoutFiles(ctx context.Context, ref string, files []string) error

CheckoutFiles restores the given files from ref into the working tree.

func (*Repository) Close

func (r *Repository) Close() error

Close releases any resources associated with the repository. Currently this is a graceful no-op (the backends do not hold persistent state), but callers should always invoke it via defer so that future resource cleanup (e.g. temporary credential helpers, cached file handles) is wired in automatically.

func (*Repository) CommitWithIdentity

func (r *Repository) CommitWithIdentity(ctx context.Context, name, email, msg string) error

CommitWithIdentity creates a commit using an explicit author identity.

func (*Repository) DeletedFiles

func (r *Repository) DeletedFiles(ctx context.Context, baseSHA, headSHA string) ([]string, error)

DeletedFiles returns the list of files deleted between two commits.

func (*Repository) Diff

func (r *Repository) Diff(ctx context.Context, baseSHA, headSHA string) (string, error)

Diff returns the textual diff between two commits.

func (*Repository) DiffNameOnly

func (r *Repository) DiffNameOnly(ctx context.Context, baseSHA, headSHA string) ([]string, error)

DiffNameOnly returns the list of files changed between two commits.

func (*Repository) Dir

func (r *Repository) Dir() string

Dir returns the on-disk path of the repository working tree.

func (*Repository) Fetch

func (r *Repository) Fetch(ctx context.Context, refspec string) error

Fetch fetches a single refspec from the "origin" remote.

func (*Repository) FetchAll

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

FetchAll fetches tags and every remote branch from the "origin" remote.

It is a single full fetch (refspec +refs/heads/*:refs/remotes/origin/* plus --tags and --prune): one network round trip instead of one per branch, and the single fetch error is propagated — per-branch failures are never silently dropped.

func (*Repository) MergeBase

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

MergeBase returns the best common ancestor of two commits.

func (*Repository) RevParse

func (r *Repository) RevParse(ctx context.Context, ref string) (string, error)

RevParse resolves a ref to its full object SHA.

type StashEntry

type StashEntry struct {
	// Index is the stash position (0 is the most recent, i.e. stash@{0}).
	Index int
	// Message is the stash list line as produced by `git stash list`.
	Message string
}

StashEntry represents a stash entry.

type StashOps

type StashOps interface {
	// StashList lists the stash entries.
	StashList(ctx context.Context, repoPath string) ([]StashEntry, error)
	// StashSave saves the working tree and index changes to the stash.
	StashSave(ctx context.Context, repoPath string, message string) error
	// StashApply applies a stash entry without removing it from the stash list.
	StashApply(ctx context.Context, repoPath string, index int) error
	// StashPop applies a stash entry and then drops it from the stash list.
	StashPop(ctx context.Context, repoPath string, index int) error
	// StashDrop removes a single stash entry.
	StashDrop(ctx context.Context, repoPath string, index int) error
	// StashClear removes all stash entries.
	StashClear(ctx context.Context, repoPath string) error
}

StashOps covers the stash list and stash lifecycle.

Backend support: the native backend implements stash via git's own refs/stash reflog. The go-git backend returns ErrStashUnsupported for every stash operation — its storage layer cannot represent the stash reflog, and earlier workarounds wrote reference names native git rejects (see gogit_stash_config.go).

type StatusCode

type StatusCode byte

StatusCode is the porcelain status code used for a file in the staging area or the working tree. These mirror the codes produced by `git status --porcelain`.

const (
	StatusUnmodified StatusCode = ' '
	StatusModified   StatusCode = 'M'
	StatusAdded      StatusCode = 'A'
	StatusDeleted    StatusCode = 'D'
	StatusRenamed    StatusCode = 'R'
	StatusCopied     StatusCode = 'C'
	StatusUntracked  StatusCode = '?'
	StatusIgnored    StatusCode = '!'
)

type StatusDiffOps

type StatusDiffOps interface {
	// GetStatus returns the working tree status.
	GetStatus(ctx context.Context, repoPath string) (*RepoStatus, error)
	// Diff returns a textual diff. With empty From/To it diffs the working tree
	// against HEAD; otherwise it diffs the two commits.
	Diff(ctx context.Context, repoPath string, opts DiffOptions) (string, error)
}

StatusDiffOps covers working-tree status and diff inspection.

type TagInfo

type TagInfo struct {
	Name string
	// Hash is the SHA the tag points at (the tag object for annotated tags,
	// or the commit for lightweight tags).
	Hash    string
	Message string
	Author  string
}

TagInfo represents a git tag.

type TagOps

type TagOps interface {
	// CreateTag creates a tag pointing at ref (or HEAD when empty).
	CreateTag(ctx context.Context, repoPath string, name string, ref string) error
	// DeleteTag deletes a local tag.
	DeleteTag(ctx context.Context, repoPath string, name string) error
	// PushTag pushes a single tag to remote.
	PushTag(ctx context.Context, repoPath string, remote string, name string, auth AuthConfig) error
	// GetTagList lists all tags with their metadata.
	GetTagList(ctx context.Context, repoPath string) ([]TagInfo, error)
}

TagOps covers tag creation, deletion, listing, and pushing.

type TreeEntry

type TreeEntry struct {
	Name string
	// Path is the full path relative to the repository root.
	Path string
	// Type is either TreeEntryFile or TreeEntryDir.
	Type TreeEntryType
	// Mode is the git file mode (e.g. "100644").
	Mode string
	Hash string
	// Size is the file size in bytes (populated for files in recursive mode).
	Size int64
}

TreeEntry represents a file or directory in a git tree.

type TreeEntryType

type TreeEntryType string

TreeEntryType identifies whether a TreeEntry is a file or a directory.

const (
	TreeEntryFile TreeEntryType = "file"
	TreeEntryDir  TreeEntryType = "dir"
)

Jump to

Keyboard shortcuts

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