git

package
v0.0.0-...-53cf7b9 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSHHostKeyVerificationStrict    = "strict"     // Require host key in known_hosts
	SSHHostKeyVerificationAcceptNew = "accept_new" // Auto-add unknown host keys
	SSHHostKeyVerificationSkip      = "skip"       // Skip host key verification (insecure)
)

SSH host key verification modes

Variables

This section is empty.

Functions

func ValidatePath

func ValidatePath(repoPath, requestedPath string) error

ValidatePath ensures the path is safe and doesn't escape the repo

Types

type AuthConfig

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

AuthConfig holds authentication configuration

type BranchInfo

type BranchInfo struct {
	Name      string
	IsDefault bool
}

BranchInfo holds information about a git branch

type Client

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

Client handles git operations

func NewClient

func NewClient(workDir string) *Client

NewClient creates a new git client

func (*Client) BrowseTree

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

BrowseTree returns the file tree at the specified path

func (*Client) Cleanup

func (c *Client) Cleanup(repoPath string) error

Cleanup removes a temporary repository directory

func (*Client) Clone

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

Clone clones a repository to a temporary directory

func (*Client) FileExists

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

FileExists checks if a file exists in the repository

func (*Client) GetCurrentCommit

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

GetCurrentCommit returns the HEAD commit hash of a cloned repository

func (*Client) ListBranches

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

ListBranches lists all branches in a remote repository

func (*Client) ReadFile

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

ReadFile reads a file from the repository

func (*Client) TestConnection

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

TestConnection tests if the repository can be accessed with the given credentials

type CommitInfo

type CommitInfo struct {
	Hash    string
	Author  string
	Message string
	Date    time.Time
}

CommitInfo holds information about a git commit

Jump to

Keyboard shortcuts

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