common

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFastForward = errors.New("not a fast-forward update")

Functions

func CommitExists

func CommitExists(ctx context.Context, repoPath, commitHash string) bool

CommitExists checks if a commit exists in the repository

func EnsureCleanAfterRestore

func EnsureCleanAfterRestore(ctx context.Context, repoPath, scope, targetCommit string) error

func ExecuteGitCommand

func ExecuteGitCommand(ctx context.Context, repoPath string, args ...string) ([]byte, error)

ExecuteGitCommand runs a git command with context

func FindGitRoot

func FindGitRoot(path string) (string, error)

FindGitRoot returns the root directory of the git repository

func GetCommitHash

func GetCommitHash(ctx context.Context, repoPath, ref string) (string, error)

GetCommitHash returns the full commit hash for a given ref

func IsRemoteRepository

func IsRemoteRepository(source string) bool

IsRemoteRepository reports whether the provided source string looks like a git remote (e.g. ssh/https/file URLs or the SCP-like "git@host:org/repo.git" syntax).

func PrepareScopedCommit

func PrepareScopedCommit(ctx context.Context, repoPath, scope string) (bool, error)

PrepareScopedCommit resets staged changes outside the provided scope, cleans untracked files, and stages the scoped path. It returns true when the scope produces staged changes.

func ValidateRepository

func ValidateRepository(repoPath string) error

ValidateRepository checks if path is within a valid Git repository

Types

type GitConfig

type GitConfig struct {
	Author  string        `json:"author,omitempty"`
	Email   string        `json:"email,omitempty"`
	Timeout time.Duration `json:"timeout,omitempty"`
}

GitConfig contains common Git configuration

type NotFastForwardError

type NotFastForwardError struct {
	TargetBranch string
	LocalHead    string
	UpstreamHead string
}

func (NotFastForwardError) Error

func (e NotFastForwardError) Error() string

func (NotFastForwardError) Is

func (e NotFastForwardError) Is(target error) bool

type ThinPackMetadata

type ThinPackMetadata struct {
	CommitHash string    `json:"commit_hash"`
	ParentHash string    `json:"parent_hash"`
	RootHash   string    `json:"root_hash"`
	FilePath   string    `json:"file_path"`
	Size       int64     `json:"size"`
	CreatedAt  time.Time `json:"created_at"`
}

ThinPackMetadata describes a thin pack file

func ParseThinPackName

func ParseThinPackName(filename string) (*ThinPackMetadata, error)

ParseThinPackName extracts metadata from thin pack filename

Jump to

Keyboard shortcuts

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