Documentation
¶
Index ¶
Constants ¶
const ( // MaxLooseObjects is the threshold for "too many" loose objects (1000) MaxLooseObjects = 1000 // MaxPacks is the threshold for "too many" pack files (3) MaxPacks = 3 // MinPackSize is the minimum size (4GB) for considering packs as "small" in housekeeping MinPackSize = 4 * strengthen.GiByte )
const ( // DefaultFileSizeLimit is the default file size threshold (50 MiB) for identifying large files DefaultFileSizeLimit = strengthen.MiByte * 50 )
const (
// ENV_GIT_QUARANTINE_PATH is the environment variable used by Git for incoming objects
ENV_GIT_QUARANTINE_PATH = "GIT_QUARANTINE_PATH"
)
const ( // VersionSupported is the only pack index version supported (v2) // Version 3 supports SHA1/SHA256 hybrid object storage but we only support v2 VersionSupported uint32 = 2 )
Variables ¶
var ( // ErrUnsupportedVersion is returned when the pack index file version is not supported ErrUnsupportedVersion = errors.New("idxfile: Unsupported version") // ErrMalformedIdxFile is returned when the pack index file is corrupted or invalid ErrMalformedIdxFile = errors.New("idxfile: Malformed IDX file") )
Functions ¶
Types ¶
type Auditor ¶ added in v0.22.0
type Auditor struct {
*Option // Embedded auditing configuration
// contains filtered or unexported fields
}
Auditor is the main analyzer for Git repository large file detection
func NewAuditor ¶ added in v0.22.0
func NewAuditor(repoPath string, shaFormat git.HashFormat, opts *Option) *Auditor
NewAuditor creates a new Auditor instance for analyzing a Git repository Parameters:
- repoPath: path to the Git repository directory
- shaFormat: the hash format (SHA1 or SHA256) used by the repository
- opts: optional filtering configuration (nil for defaults)
func (*Auditor) Delta ¶ added in v0.22.0
Delta returns the size increment for quarantine mode analysis
func (*Auditor) Du ¶ added in v0.22.0
Du performs disk usage analysis of the Git repository In quarantine mode, also analyzes incoming objects in GIT_QUARANTINE_PATH
func (*Auditor) Execute ¶ added in v0.22.0
Execute performs the complete repository analysis: 1. Analyzes disk usage of loose objects and pack files 2. Calls the SizeReceiver callback with total size if provided 3. Analyzes each pack file for large objects
func (*Auditor) HashLen ¶ added in v0.22.0
HashLen returns the hash length in bytes (20 for SHA1, 32 for SHA256)
type Option ¶ added in v0.22.0
type Option struct {
// Limit is the file size threshold in bytes. Files larger than this will be rejected.
Limit int64
// OnOversized is a callback function called for each file that exceeds the limit.
// Returns an error to stop processing, or nil to continue.
OnOversized func(oid string, size int64) error
// QuarantineMode enables analysis of incoming objects in Git quarantine mode.
// When enabled, analyzes both the main repository and quarantine directory.
QuarantineMode bool
}
Option configures the auditing behavior for repository analysis
type Result ¶
type Result struct {
Size int64 // Total repository size in bytes
LooseObjects int // Number of loose objects
Packs []*Pack // List of pack files
TmpPacks uint32 // Count of temporary pack files
}
Result contains the results of repository housekeeping scan
func HousekeepingScan ¶
HousekeepingScan performs a repository housekeeping analysis Returns Result struct with repository statistics and maintenance status This function is useful for determining if a repository needs git gc/repack