git

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: BSD-3-Clause Imports: 42 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CloneScratchPrefix = "gitops-"

	SSHHostKeyVerificationStrict    = "strict"
	SSHHostKeyVerificationAcceptNew = "accept_new"
	SSHHostKeyVerificationSkip      = "skip" // Skip host key verification (insecure)

)

Variables

View Source
var (
	ErrPushRejected        = errors.New("push rejected: remote branch was updated by another writer")
	ErrInvalidCommit       = errors.New("invalid commit hash")
	ErrSelectionUnreadable = errors.New("selection is unreadable")
	ErrSelectionLimits     = errors.New("selection exceeds limits")
	ErrSelectionInvalid    = errors.New("selection is invalid")
)

Functions

func ExecutableFiles added in v3.1.0

func ExecutableFiles(repoPath string) (map[string]bool, error)

func ParseSigningKey

func ParseSigningKey(armored, passphrase string) (*openpgp.Entity, error)

func RepositoryAttribute

func RepositoryAttribute(rawURL string) attribute.KeyValue

func ValidatePath

func ValidatePath(repoPath, requestedPath string) error

Types

type AuthConfig

type AuthConfig struct {
	AuthType               string
	Username               string
	Token                  string
	SSHKey                 string
	SSHHostKeyVerification string // strict, accept_new, skip
}

type BranchInfo

type BranchInfo struct {
	Name      string
	IsDefault bool
}

type Client

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

func NewClient

func NewClient(workDir string) *Client

func (*Client) BrowseTree

func (c *Client) BrowseTree(ctx context.Context, repoPath, targetPath string) ([]types.FileTreeNode, error)

func (*Client) CheckoutForWrite

func (c *Client) CheckoutForWrite(ctx context.Context, url, branch string, auth AuthConfig) (*WriteCheckout, error)

func (*Client) Clone

func (c *Client) Clone(ctx context.Context, url, branch string, auth AuthConfig, depth int) (repoPath string, err error)

func (*Client) CommitAndPush

func (c *Client) CommitAndPush(ctx context.Context, checkout *WriteCheckout, req CommitRequest, auth AuthConfig) (string, bool, error)

func (*Client) CommitDiff

func (c *Client) CommitDiff(ctx context.Context, repoPath, commitHash, directory string) (HistoryEntry, []FileDiff, error)

func (*Client) DirectoryHistory

func (c *Client) DirectoryHistory(ctx context.Context, repoPath, directory string, limit int) ([]HistoryEntry, error)

func (*Client) Discard

func (c *Client) Discard(ctx context.Context, repoPath string)

func (*Client) FileExists

func (c *Client) FileExists(ctx context.Context, repoPath, filePath string) bool

func (*Client) GetCurrentCommit

func (c *Client) GetCurrentCommit(ctx context.Context, repoPath string) (string, error)

func (*Client) ListBranches

func (c *Client) ListBranches(ctx context.Context, url string, auth AuthConfig) ([]BranchInfo, error)

func (*Client) ProbeRemote

func (c *Client) ProbeRemote(ctx context.Context, url string, auth AuthConfig) error

func (*Client) PurgeScratchDirs

func (c *Client) PurgeScratchDirs(ctx context.Context, maxAge time.Duration) (int, error)

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, repoPath, filePath string) (string, error)

func (*Client) RemoteBranchHead

func (c *Client) RemoteBranchHead(ctx context.Context, url, branch string, auth AuthConfig) (string, bool, error)

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context, url, branch string, auth AuthConfig) error

func (*Client) WalkDirectory

func (c *Client) WalkDirectory(ctx context.Context, repoPath, composePath string,
	maxFiles int, maxTotalSize, maxBinarySize int64,
) (*DirectoryWalkResult, error)

type CollectOptions

type CollectOptions struct {
	SkipDir      func(name string) bool
	SkipFile     func(name string) bool
	MaxFiles     int
	MaxTotalSize int64
}

type CommitFile

type CommitFile struct {
	Path       string
	Content    []byte
	Executable bool
}

func CollectFiles

func CollectFiles(ctx context.Context, root string, selection []string, opts CollectOptions) ([]CommitFile, error)

type CommitIdentity

type CommitIdentity struct {
	SignKey *openpgp.Entity
	Name    string
	Email   string
}

type CommitRequest

type CommitRequest struct {
	SignKey     *openpgp.Entity
	Message     string
	AuthorName  string
	AuthorEmail string
	Files       []CommitFile
	Remove      []string
}

type DirectoryWalkResult

type DirectoryWalkResult struct {
	Files           []SyncFileInfo
	TotalFiles      int
	TotalSize       int64
	SkippedBinaries int
}

type FileDiff

type FileDiff struct {
	Path  string
	Patch string
}

type HistoryEntry

type HistoryEntry struct {
	Hash    string
	Author  string
	Email   string
	Message string
	Date    time.Time
	Files   []string
}

type SyncFileInfo

type SyncFileInfo struct {
	RelativePath string
	Content      []byte
	Size         int64
	IsBinary     bool
	Executable   bool
}

type WriteCheckout

type WriteCheckout struct {
	RepoPath   string
	Branch     string
	HeadCommit string

	BranchExists bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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