stats

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright (c) 2016-present GitLab Inc. SPDX-License-Identifier: MIT

Copyright (c) 2016-present GitLab Inc. SPDX-License-Identifier: MIT

Index

Constants

View Source
const (
	LargePackThreshold uint64 = 2 * 1024 * 1024 * 1024
	PackSizeTotal      uint64 = 8 * 1024 * 1024 * 1024
)
View Source
const (
	// StaleObjectsGracePeriod is time delta that is used to indicate cutoff wherein an object
	// would be considered old. Currently this is set to being 10 days.
	StaleObjectsGracePeriod = -10 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func LooseObjects

func LooseObjects(repoPath string) (uint64, error)

LooseObjects returns the number of loose objects that are not in a packfile.

func PackfilesCount

func PackfilesCount(repoPath string) (uint64, error)

PackfilesCount returns the number of packfiles a repository has.

Types

type BitmapStat

type BitmapStat struct {
	// Exists indicates whether the bitmap exists. This field would usually always be `true`
	// when read via `BitmapInfoForPath()`, but helps when the bitmap info is embedded into
	// another structure where it may only be conditionally read.
	Exists bool `json:"exists"`
	// Version is the version of the bitmap. Currently, this is expected to always be 1.
	Version uint16 `json:"version"`
	// HasHashCache indicates whether the name hash cache extension exists in the bitmap. This
	// extension records hashes of the path at which trees or blobs are found at the time of
	// writing the packfile so that it becomes possible to quickly find objects stored at the
	// same path. This mechanism is fed into the delta compression machinery to make the delta
	// heuristics more effective.
	HasHashCache bool `json:"has_hash_cache"`
	// HasLookupTable indicates whether the lookup table exists in the bitmap. Lookup tables
	// allow to defer loading bitmaps until required and thus speed up read-only bitmap
	// preparations.
	HasLookupTable bool `json:"has_lookup_table"`
}

BitmapStat contains information about a packfile or multi-pack-index bitmap.

func BitmapStatus

func BitmapStatus(path string) (BitmapStat, error)

BitmapStatus reads the bitmap at the given path and returns information on that bitmap.

type CommitGraphInfo

type CommitGraphInfo struct {
	// Exists tells whether a commit-graph exists.
	Exists bool `json:"exists"`
	// CommitGraphChainLength is the length of the commit-graph chain, if it exists. If the
	// repository does not have a commit-graph chain but a monolithic commit-graph, then this
	// field will be set to 0.
	CommitGraphChainLength uint64 `json:"commit_graph_chain_length"`
	// HasBloomFilters tells whether the commit-graph has bloom filters. Bloom filters are used
	// to answer the question whether a certain path has been changed in the commit the bloom
	// filter applies to.
	HasBloomFilters bool `json:"has_bloom_filters"`
	// HasGenerationData tells whether the commit-graph has generation data. Generation
	// data is stored as the corrected committer date, which is defined as the maximum
	// of the commit's own committer date or the corrected committer date of any of its
	// parents. This data can be used to determine whether a commit A comes after a
	// certain commit B.
	HasGenerationData bool `json:"has_generation_data"`
	// HasGenerationDataOverflow stores overflow data in case the corrected committer
	// date takes more than 31 bits to represent.
	HasGenerationDataOverflow bool `json:"has_generation_data_overflow"`
}

CommitGraphInfo returns information about the commit-graph of a repository.

func CommitGraphInfoForRepository

func CommitGraphInfoForRepository(repoPath string) (CommitGraphInfo, error)

CommitGraphInfoForRepository derives information about commit-graphs in the repository.

Please refer to https://git-scm.com/docs/commit-graph#_file_layout for further information about the commit-graph format.

type LFSObjectsStat

type LFSObjectsStat struct {
	Count uint64 `json:"count"`
	Size  uint64 `json:"size"`
}

func LFSObjectsStatus

func LFSObjectsStatus(repoPath string) (LFSObjectsStat, error)

type LooseObjectsStat

type LooseObjectsStat struct {
	// Count is the number of loose objects.
	Count uint64 `json:"count"`
	// Size is the total size of all loose objects in bytes.
	Size uint64 `json:"size"`
	// StaleCount is the number of stale loose objects when taking into account the specified cutoff
	// date.
	StaleCount uint64 `json:"stale_count"`
	// StaleSize is the total size of stale loose objects when taking into account the specified
	// cutoff date.
	StaleSize uint64 `json:"stale_size"`
	// GarbageCount is the number of garbage files in the loose-objects shards.
	GarbageCount uint64 `json:"garbage_count"`
	// GarbageSize is the total size of garbage in the loose-objects shards.
	GarbageSize uint64 `json:"garbage_size"`
}

LooseObjectsStat contains information about loose objects.

func LooseObjectsStatus

func LooseObjectsStatus(repoPath string, cutoffDate time.Time) (LooseObjectsStat, error)

LooseObjectsStatus derives information about loose objects in the repository. If a cutoff date is given, then this function will only take into account objects which are older than the given point in time.

type MultiPackIndexStat

type MultiPackIndexStat struct {
	// Exists determines whether the multi-pack-index exists or not.
	Exists bool `json:"exists"`
	// Version is the version of the multi-pack-index. Currently, Git only recognizes version 1.
	Version uint8 `json:"version"`
	// PackfileCount is the count of packfiles that the multi-pack-index tracks.
	PackfileCount uint64 `json:"packfile_count"`
}

func MultiPackIndexStatus

func MultiPackIndexStatus(path string) (MultiPackIndexStat, error)

MultiPackIndexStatus reads the multi-pack-index at the given path and returns information on it. Returns an error in case the file cannot be read or in case its format is not understood.

type PackEntry

type PackEntry struct {
	Name string `json:"name"`
	Size uint64 `json:"size"`
}

type PackfilesStat

type PackfilesStat struct {
	// Count is the number of all packfiles, including stale and kept ones.
	Count uint64 `json:"count"`
	// Size is the total size of all packfiles in bytes, including stale and kept ones.
	Size uint64 `json:"size"`
	// PackEntries small pack count
	PackEntries []PackEntry `json:"entries"`
	// ReverseIndexCount is the number of reverse indices.
	ReverseIndexCount uint64 `json:"reverse_index_count"`
	// CruftCount is the number of cruft packfiles which have a .mtimes file.
	CruftCount uint64 `json:"cruft_count"`
	// CruftSize is the size of cruft packfiles which have a .mtimes file.
	CruftSize uint64 `json:"cruft_size"`
	// KeepCount is the number of .keep packfiles.
	KeepCount uint64 `json:"keep_count"`
	// KeepSize is the size of .keep packfiles.
	KeepSize uint64 `json:"keep_size"`
	// GarbageCount is the number of garbage files.
	GarbageCount uint64 `json:"garbage_count"`
	// GarbageSize is the total size of all garbage files in bytes.
	GarbageSize uint64 `json:"garbage_size"`
	// Bitmap contains information about the bitmap, if any exists.
	Bitmap BitmapStat `json:"bitmap"`
	// MultiPackIndex confains information about the multi-pack-index, if any exists.
	MultiPackIndex MultiPackIndexStat `json:"multi_pack_index"`
	// MultiPackIndexBitmap contains information about the bitmap for the multi-pack-index, if
	// any exists.
	MultiPackIndexBitmap BitmapStat `json:"multi_pack_index_bitmap"`
}

PackfilesStat contains information about packfiles.

func PackfilesStatus

func PackfilesStatus(repoPath string) (PackfilesStat, error)

PackfilesStatus derives various information about packfiles for the given repository.

func (PackfilesStat) NoLargePack

func (pi PackfilesStat) NoLargePack() bool

type ReferencesStat

type ReferencesStat struct {
	// LooseReferencesCount is the number of unpacked, loose references that exist.
	LooseReferencesCount uint64 `json:"loose_references_count"`
	// PackedReferencesSize is the size of the packed-refs file in bytes.
	PackedReferencesSize uint64 `json:"packed_references_size"`
	// ReftableTables contains details of individual table files.
	ReftableTables []ReftableTable `json:"reftable_tables"`
	// ReftableUnrecognizedFilesCount is the number of files under the `reftables/`
	// directory that shouldn't exist, according to the entries in `tables.list`.
	ReftableUnrecognizedFilesCount uint64 `json:"reftable_unrecognized_files"`
	// ReferenceBackendName denotes the reference backend name of the repo.
	ReferenceBackendName string `json:"reference_backend"`
}

ReferencesStat contains information about references.

func ReferencesStatus

func ReferencesStatus(ctx context.Context, repoPath string, refFormat string) (ReferencesStat, error)

ReferencesStatus derives information about references in the repository.

type ReftableTable

type ReftableTable struct {
	// Size is the size in bytes.
	Size uint64 `json:"size"`
	// UpdateIndexMin is the min_update_index of the reftable table. This is derived
	// from the filename only.
	UpdateIndexMin uint64 `json:"update_index_min"`
	// UpdateIndexMax is the max_update_index of the reftable table. This is derived
	// from the filename only.
	UpdateIndexMax uint64 `json:"update_index_max"`
}

ReftableTable contains information about an individual reftable table.

type Stat

type Stat struct {
	// LooseObjects contains information about loose objects.
	LooseObjects LooseObjectsStat `json:"loose_objects"`
	// Packfiles contains information about packfiles.
	Packfiles PackfilesStat `json:"packfiles"`
	// References contains information about the repository's references.
	References ReferencesStat `json:"references"`
	// CommitGraph contains information about the repository's commit-graphs.
	CommitGraph CommitGraphInfo `json:"commit_graph"`
	LFS         LFSObjectsStat  `json:"lfs"`
}

Stat contains information about the repository.

func Status

func Status(ctx context.Context, repoPath string, refFormat string) (Stat, error)

Status computes the RepositoryInfo for a repository.

Jump to

Keyboard shortcuts

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