git

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRepoRoot

func FindRepoRoot(path string) string

FindRepoRoot finds the git repository root for a given path Returns empty string if not in a git repository This is a fast operation that doesn't compute status

func GenerateRootIDFromGit

func GenerateRootIDFromGit(path string) string

GenerateRootIDFromGit generates a deterministic root ID from git remote URL and relative path If no remote URL is available, returns empty string

func GenerateRootIDFromMultiPaths added in v0.1.1

func GenerateRootIDFromMultiPaths(commonRoot string, subPaths []string) string

GenerateRootIDFromMultiPaths generates a deterministic root ID for a multi-path scan. It hashes the common root together with the sorted list of direct subfolder names, so different subsets of paths produce different IDs while the same set is stable. The subPaths must be the relative subfolder names (not full paths). If the common root is a git repo with a remote URL, the git-based identity is used as the base instead of the filesystem path, ensuring portability across machines.

func GenerateRootIDFromPath

func GenerateRootIDFromPath(basePath string) string

GenerateRootIDFromPath generates a deterministic root ID from absolute path Used when git repository is not available

Types

type GitInfo

type GitInfo struct {
	Branch    string `json:"branch,omitempty"`
	Commit    string `json:"commit,omitempty"`
	RemoteURL string `json:"remote_url,omitempty"`
}

GitInfo contains git repository information

func GetGitInfo

func GetGitInfo(path string) *GitInfo

GetGitInfo retrieves git repository information for the given path Consider using GetGitInfoCached for better performance in recursive scans

func GetGitInfoWithRoot

func GetGitInfoWithRoot(path string) (*GitInfo, string)

GetGitInfoWithRoot retrieves git info and returns the repository root path This allows callers to cache by repo root for better performance

type GitignoreStack

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

GitignoreStack represents a stack of .gitignore pattern sets

func NewGitignoreStack

func NewGitignoreStack() *GitignoreStack

NewGitignoreStack creates a new empty gitignore stack

func (*GitignoreStack) GetAllPatterns

func (gs *GitignoreStack) GetAllPatterns() []string

GetAllPatterns returns all patterns from the entire stack (in order)

func (*GitignoreStack) GetStackDepth

func (gs *GitignoreStack) GetStackDepth() int

GetStackDepth returns the current depth of the stack

func (*GitignoreStack) Pop

func (gs *GitignoreStack) Pop()

Pop removes the top pattern set from the stack

func (*GitignoreStack) Push

func (gs *GitignoreStack) Push(directory string, patterns []string)

Push adds patterns from a .gitignore file to the stack

func (*GitignoreStack) ShouldExclude

func (gs *GitignoreStack) ShouldExclude(name, relativePath string) bool

ShouldExclude checks if a file/directory should be excluded based on the current stack

type Loader

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

Loader handles loading ignore patterns from .gitignore files (legacy approach)

func NewGitignoreLoader

func NewGitignoreLoader() *Loader

NewGitignoreLoader creates a new gitignore loader

func NewGitignoreLoaderWithLogger

func NewGitignoreLoaderWithLogger(prog *progress.Progress, logger *slog.Logger) *Loader

NewGitignoreLoaderWithLogger creates a new gitignore loader with logging

func NewGitignoreLoaderWithProgress

func NewGitignoreLoaderWithProgress(prog *progress.Progress) *Loader

NewGitignoreLoaderWithProgress creates a new gitignore loader with progress reporting

func (*Loader) LoadPatterns

func (l *Loader) LoadPatterns(scanPath string) ([]string, error)

LoadPatterns loads ignore patterns from .gitignore files recursively Searches from the scan path down through all subdirectories Skips .gitignore files in directories that are typically cache/temp directories

func (*Loader) LoadPatternsFromFile

func (l *Loader) LoadPatternsFromFile(gitignorePath string) ([]string, error)

LoadPatternsFromFile loads patterns from a specific .gitignore file path Useful for testing or custom paths

type PatternSet

type PatternSet struct {
	Directory string   // Directory where this .gitignore was found
	Patterns  []string // Patterns from this .gitignore
}

PatternSet represents patterns from a single .gitignore file

type StackBasedLoader

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

StackBasedLoader handles loading ignore patterns in a stack-based approach

func NewStackBasedLoader

func NewStackBasedLoader() *StackBasedLoader

NewStackBasedLoader creates a new stack-based gitignore loader

func NewStackBasedLoaderWithLogger

func NewStackBasedLoaderWithLogger(prog *progress.Progress, logger *slog.Logger) *StackBasedLoader

NewStackBasedLoaderWithLogger creates a new stack-based gitignore loader with logging

func NewStackBasedLoaderWithProgress

func NewStackBasedLoaderWithProgress(prog *progress.Progress) *StackBasedLoader

NewStackBasedLoaderWithProgress creates a new stack-based gitignore loader with progress reporting

func (*StackBasedLoader) GetStack

func (l *StackBasedLoader) GetStack() *GitignoreStack

GetStack returns the current gitignore stack (for testing/debugging)

func (*StackBasedLoader) InitializeWithTopLevelExcludes

func (l *StackBasedLoader) InitializeWithTopLevelExcludes(basePath string, excludePatterns []string, configExcludes []string) error

InitializeWithTopLevelExcludes adds config and CLI excludes as a top-level pseudo .gitignore

func (*StackBasedLoader) LoadAndPushGitignore

func (l *StackBasedLoader) LoadAndPushGitignore(directory string) bool

LoadAndPushGitignore loads .gitignore for directory and pushes to stack if found Returns true if .gitignore was found and loaded successfully

func (*StackBasedLoader) PopGitignore

func (l *StackBasedLoader) PopGitignore()

PopGitignore removes patterns from stack when leaving directory

func (*StackBasedLoader) ShouldExclude

func (l *StackBasedLoader) ShouldExclude(name, relativePath string) bool

ShouldExclude checks if a file/directory should be excluded based on current stack

Jump to

Keyboard shortcuts

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