sizes

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewThresholdFlagValue

func NewThresholdFlagValue(threshold *Threshold, value Threshold) pflag.Value

Types

type BlobSize

type BlobSize struct {
	Size counts.Count32
}

func (BlobSize) String

func (s BlobSize) String() string

type CommitSize

type CommitSize struct {
	// The height of the ancestor graph, including this commit.
	MaxAncestorDepth counts.Count32 `json:"max_ancestor_depth"`
}

func (CommitSize) String

func (s CommitSize) String() string

type Footnotes added in v1.3.0

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

func NewFootnotes added in v1.3.0

func NewFootnotes() *Footnotes

func (*Footnotes) CreateCitation added in v1.3.0

func (f *Footnotes) CreateCitation(footnote string) string

func (*Footnotes) String added in v1.3.0

func (f *Footnotes) String() string

type Graph

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

An object graph that is being built up.

func NewGraph

func NewGraph(nameStyle NameStyle) *Graph

func (*Graph) GetBlobSize

func (g *Graph) GetBlobSize(oid git.OID) BlobSize

func (*Graph) GetCommitSize

func (g *Graph) GetCommitSize(oid git.OID) CommitSize

func (*Graph) GetTreeSize

func (g *Graph) GetTreeSize(oid git.OID) TreeSize

func (*Graph) HistorySize

func (g *Graph) HistorySize() HistorySize

func (*Graph) RegisterBlob

func (g *Graph) RegisterBlob(oid git.OID, objectSize counts.Count32)

Record that the specified `oid` is a blob with the specified size.

func (*Graph) RegisterCommit

func (g *Graph) RegisterCommit(oid git.OID, commit *git.Commit)

Record that the specified `oid` is the specified `commit`.

func (*Graph) RegisterReference

func (g *Graph) RegisterReference(ref git.Reference)

func (*Graph) RegisterTag

func (g *Graph) RegisterTag(oid git.OID, tag *git.Tag)

Record that the specified `oid` is the specified `tag`.

func (*Graph) RegisterTree

func (g *Graph) RegisterTree(oid git.OID, tree *git.Tree) error

Record that the specified `oid` is the specified `tree`.

func (*Graph) RequireTagSize

func (g *Graph) RequireTagSize(oid git.OID, listener func(TagSize)) (TagSize, bool)

func (*Graph) RequireTreeSize

func (g *Graph) RequireTreeSize(oid git.OID, listener func(TreeSize)) (TreeSize, bool)

type HistorySize

type HistorySize struct {
	// The total number of unique commits analyzed.
	UniqueCommitCount counts.Count32 `json:"unique_commit_count"`

	// The total size of all commits analyzed.
	UniqueCommitSize counts.Count64 `json:"unique_commit_size"`

	// The maximum size of any analyzed commit.
	MaxCommitSize counts.Count32 `json:"max_commit_size"`

	// The commit with the maximum size.
	MaxCommitSizeCommit *Path `json:"max_commit,omitempty"`

	// The maximum ancestor depth of any analyzed commit.
	MaxHistoryDepth counts.Count32 `json:"max_history_depth"`

	// The maximum number of direct parents of any analyzed commit.
	MaxParentCount counts.Count32 `json:"max_parent_count"`

	// The commit with the maximum number of direct parents.
	MaxParentCountCommit *Path `json:"max_parent_count_commit,omitempty"`

	// The total number of unique trees analyzed.
	UniqueTreeCount counts.Count32 `json:"unique_tree_count"`

	// The total size of all trees analyzed.
	UniqueTreeSize counts.Count64 `json:"unique_tree_size"`

	// The total number of tree entries in all unique trees analyzed.
	UniqueTreeEntries counts.Count64 `json:"unique_tree_entries"`

	// The maximum number of entries an a tree.
	MaxTreeEntries counts.Count32 `json:"max_tree_entries"`

	// The tree with the maximum number of entries.
	MaxTreeEntriesTree *Path `json:"max_tree_entries_tree,omitempty"`

	// The total number of unique blobs analyzed.
	UniqueBlobCount counts.Count32 `json:"unique_blob_count"`

	// The total size of all of the unique blobs analyzed.
	UniqueBlobSize counts.Count64 `json:"unique_blob_size"`

	// The maximum size of any analyzed blob.
	MaxBlobSize counts.Count32 `json:"max_blob_size"`

	// The biggest blob found.
	MaxBlobSizeBlob *Path `json:"max_blob_size_blob,omitempty"`

	// The total number of unique tag objects analyzed.
	UniqueTagCount counts.Count32 `json:"unique_tag_count"`

	// The maximum number of tags in a chain.
	MaxTagDepth counts.Count32 `json:"max_tag_depth"`

	// The tag with the maximum tag depth.
	MaxTagDepthTag *Path `json:"max_tag_depth_tag,omitempty"`

	// The number of references analyzed. Note that we don't eliminate
	// duplicates if the user passes the same reference more than
	// once.
	ReferenceCount counts.Count32 `json:"reference_count"`

	// The maximum depth of trees and blobs starting at this object
	// (not including this object).
	MaxPathDepth counts.Count32 `json:"max_path_depth"`

	// The tree with the maximum path depth.
	MaxPathDepthTree *Path `json:"max_path_depth_tree,omitempty"`

	// The maximum length of any path relative to this object, in
	// characters.
	MaxPathLength counts.Count32 `json:"max_path_length"`

	// The tree with the maximum path length.
	MaxPathLengthTree *Path `json:"max_path_length_tree,omitempty"`

	// The total number of trees, including duplicates.
	MaxExpandedTreeCount counts.Count32 `json:"max_expanded_tree_count"`

	// The tree with the maximum expanded tree count.
	MaxExpandedTreeCountTree *Path `json:"max_expanded_tree_count_tree,omitempty"`

	// The total number of blobs, including duplicates.
	MaxExpandedBlobCount counts.Count32 `json:"max_expanded_blob_count"`

	// The tree with the maximum expanded blob count.
	MaxExpandedBlobCountTree *Path `json:"max_expanded_blob_count_tree,omitempty"`

	// The total size of all blobs, including duplicates.
	MaxExpandedBlobSize counts.Count64 `json:"max_expanded_blob_size"`

	// The tree with the maximum expanded blob size.
	MaxExpandedBlobSizeTree *Path `json:"max_expanded_blob_size_tree,omitempty"`

	// The total number of symbolic links, including duplicates.
	MaxExpandedLinkCount counts.Count32 `json:"max_expanded_link_count"`

	// The tree with the maximum expanded link count.
	MaxExpandedLinkCountTree *Path `json:"max_expanded_link_count_tree,omitempty"`

	// The total number of submodules referenced, including duplicates.
	MaxExpandedSubmoduleCount counts.Count32 `json:"max_expanded_submodule_count"`

	// The tree with the maximum expanded submodule count.
	MaxExpandedSubmoduleCountTree *Path `json:"max_expanded_submodule_count_tree,omitempty"`
}

func ScanRepositoryUsingGraph

func ScanRepositoryUsingGraph(
	repo *git.Repository, filter git.ReferenceFilter, nameStyle NameStyle, progress bool,
) (HistorySize, error)

func (HistorySize) JSON added in v1.3.0

func (s HistorySize) JSON(threshold Threshold, nameStyle NameStyle) ([]byte, error)

func (HistorySize) String

func (s HistorySize) String() string

func (HistorySize) TableString

func (s HistorySize) TableString(threshold Threshold, nameStyle NameStyle) string

type InOrderPathResolver

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

func (*InOrderPathResolver) ForgetPath

func (pr *InOrderPathResolver) ForgetPath(p *Path)

Record that the specified path is wanted by one less seeker. If its seeker count goes to zero, remove it from `pr.soughtPaths`.

func (*InOrderPathResolver) RecordCommit

func (pr *InOrderPathResolver) RecordCommit(oid, tree git.OID)

func (*InOrderPathResolver) RecordReference

func (pr *InOrderPathResolver) RecordReference(ref git.Reference)

func (*InOrderPathResolver) RecordTag

func (pr *InOrderPathResolver) RecordTag(oid git.OID, tag *git.Tag)

func (*InOrderPathResolver) RecordTreeEntry

func (pr *InOrderPathResolver) RecordTreeEntry(oid git.OID, name string, childOID git.OID)

Record that the tree with OID `oid` has an entry with the specified `name` and `childOID`.

func (*InOrderPathResolver) RequestPath

func (pr *InOrderPathResolver) RequestPath(oid git.OID, objectType string) *Path

Request that a path to the object named `oid` be computed.

type NameStyle

type NameStyle int
const (
	NameStyleNone NameStyle = iota
	NameStyleHash
	NameStyleFull
)

func (*NameStyle) Set

func (n *NameStyle) Set(s string) error

func (*NameStyle) String

func (n *NameStyle) String() string

Methods to implement pflag.Value:

func (*NameStyle) Type

func (n *NameStyle) Type() string

type NullPathResolver

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

func (NullPathResolver) ForgetPath

func (_ NullPathResolver) ForgetPath(p *Path)

func (NullPathResolver) RecordCommit

func (_ NullPathResolver) RecordCommit(oid, tree git.OID)

func (NullPathResolver) RecordReference

func (_ NullPathResolver) RecordReference(ref git.Reference)

func (NullPathResolver) RecordTag

func (_ NullPathResolver) RecordTag(oid git.OID, tag *git.Tag)

func (NullPathResolver) RecordTreeEntry

func (_ NullPathResolver) RecordTreeEntry(oid git.OID, name string, childOID git.OID)

func (NullPathResolver) RequestPath

func (n NullPathResolver) RequestPath(oid git.OID, objectType string) *Path

type Path

type Path struct {
	// The OID of the object whose path we seek. This member is always
	// set.
	git.OID
	// contains filtered or unexported fields
}

Structure for keeping track of an object whose path we want to know (e.g., the biggest blob, or a tree containing the biggest blob, or a commit whose tree contains the biggest blob). Valid states:

  • `parent == nil && relativePath == ""`—we have not yet found anything that refers to this object.
  • `parent != nil && relativePath == ""`—this object is a tree, and we have found a commit that refers to it.
  • `parent == nil && relativePath != ""`—we have found a reference that points directly at this object; `relativePath` is the full name of the reference.
  • `parent != nil && relativePath != ""`—this object is a blob or tree, and we have found another tree that refers to it; `relativePath` is the corresponding tree entry name.

func (*Path) BestPath

func (p *Path) BestPath() string

Return some human-readable path for this object, even if it's just the OID.

func (*Path) MarshalJSON

func (p *Path) MarshalJSON() ([]byte, error)

func (*Path) Path

func (p *Path) Path() string

Return a human-readable path for this object if we can do better than its OID; otherwise, return "".

func (*Path) String

func (p *Path) String() string

func (*Path) TreePrefix

func (p *Path) TreePrefix() string

Return the path of this object under the assumption that another path component will be appended to it.

type PathResolver

type PathResolver interface {
	RequestPath(oid git.OID, objectType string) *Path
	ForgetPath(p *Path)
	RecordReference(ref git.Reference)
	RecordTreeEntry(oid git.OID, name string, childOID git.OID)
	RecordCommit(oid, tree git.OID)
	RecordTag(oid git.OID, tag *git.Tag)
}

PathResolver figures out a "reachability path" (i.e., Git `rev-parse` input, including commit and/or file path) by which specified objects are reachable. It is used as follows:

  • Request an object's path using `RequestPath()`. The returned `Path` object is a placeholder for the object's path.
  • Tell the `PathResolver` about objects that might be along the object's reachability path, *in depth-first* order (i.e., referents before referers) by calling `RecordTree()`, `RecordCommit()`, `RecordTag()`, and `RecordReference()`,.

* Read the path out of the `Path` object using `Path.Path()`.

Multiple objects can be processed at once.

It is important that interested is registered in an object's path via `RequestPath()` *before* any of the objects along its reachability path are recorded.

If a caller decides that it is not interested in a path after all, it can call `ForgetPath()`. This might free up some resources that would otherwise continue consuming memory.

func NewPathResolver

func NewPathResolver(nameStyle NameStyle) PathResolver

type Size

type Size interface {
	fmt.Stringer
}

type TagSize

type TagSize struct {
	// The number of tags that have to be traversed (including this
	// one) to get to an object.
	TagDepth counts.Count32
}

func (TagSize) String

func (s TagSize) String() string

type Threshold

type Threshold float64

func (*Threshold) Set

func (t *Threshold) Set(s string) error

func (*Threshold) String

func (t *Threshold) String() string

Methods to implement pflag.Value:

func (*Threshold) Type

func (t *Threshold) Type() string

type TreeSize

type TreeSize struct {
	// The maximum depth of trees and blobs starting at this object
	// (not including this object).
	MaxPathDepth counts.Count32 `json:"max_path_depth"`

	// The maximum length of any path relative to this object, in
	// characters.
	MaxPathLength counts.Count32 `json:"max_path_length"`

	// The total number of trees, including duplicates.
	ExpandedTreeCount counts.Count32 `json:"expanded_tree_count"`

	// The total number of blobs, including duplicates.
	ExpandedBlobCount counts.Count32 `json:"expanded_blob_count"`

	// The total size of all blobs, including duplicates.
	ExpandedBlobSize counts.Count64 `json:"expanded_blob_size"`

	// The total number of symbolic links, including duplicates.
	ExpandedLinkCount counts.Count32 `json:"expanded_link_count"`

	// The total number of submodules referenced, including duplicates.
	ExpandedSubmoduleCount counts.Count32 `json:"expanded_submodule_count"`
}

func (TreeSize) String

func (s TreeSize) String() string

Jump to

Keyboard shortcuts

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