plumbing

package
v10.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigBlobCacheFailOnMissingSubmodules is the name of the configuration option for
	// BlobCache.Configure() to check if the referenced submodules are registered in .gitignore.
	ConfigBlobCacheFailOnMissingSubmodules = "BlobCache.FailOnMissingSubmodules"
	// DependencyBlobCache identifies the dependency provided by BlobCache.
	DependencyBlobCache = "blob_cache"
)
View Source
const (
	// ConfigFileDiffDisableCleanup is the name of the configuration option (FileDiff.Configure())
	// to suppress diffmatchpatch.DiffCleanupSemanticLossless() which is supposed to improve
	// the human interpretability of diffs.
	ConfigFileDiffDisableCleanup = "FileDiff.NoCleanup"

	// DependencyFileDiff is the name of the dependency provided by FileDiff.
	DependencyFileDiff = "file_diff"

	// ConfigFileWhitespaceIgnore is the name of the configuration option (FileDiff.Configure())
	// to suppress whitespace changes which can pollute the core diff of the files
	ConfigFileWhitespaceIgnore = "FileDiff.WhitespaceIgnore"

	// ConfigFileDiffTimeout is the number of milliseconds a single diff calculation may elapse.
	// We need this timeout to avoid spending too much time comparing big or "bad" files.
	ConfigFileDiffTimeout = "FileDiff.Timeout"
)
View Source
const (
	// RenameAnalysisDefaultThreshold specifies the default percentage of common lines in a pair
	// of files to consider them linked. The exact code of the decision is sizesAreClose().
	// CGit's default is 50%. Ours is 80% because 50% can be too computationally expensive.
	RenameAnalysisDefaultThreshold = 80

	// RenameAnalysisDefaultTimeout is the default value of RenameAnalysis.Timeout (in milliseconds).
	RenameAnalysisDefaultTimeout = 60000

	// ConfigRenameAnalysisSimilarityThreshold is the name of the configuration option
	// (RenameAnalysis.Configure()) which sets the similarity threshold.
	ConfigRenameAnalysisSimilarityThreshold = "RenameAnalysis.SimilarityThreshold"

	// ConfigRenameAnalysisTimeout is the name of the configuration option
	// (RenameAnalysis.Configure()) which sets the maximum time allowed to spend
	// computing renames in a single commit.
	ConfigRenameAnalysisTimeout = "RenameAnalysis.Timeout"

	// RenameAnalysisMinimumSize is the minimum size of a blob to be considered.
	RenameAnalysisMinimumSize = 32

	// RenameAnalysisMaxCandidates is the maximum number of rename candidates to consider per file.
	RenameAnalysisMaxCandidates = 50

	// RenameAnalysisSetSizeLimit is the maximum number of added + removed files for
	// RenameAnalysisMaxCandidates to be active; the bigger numbers set it to 1.
	RenameAnalysisSetSizeLimit = 1000

	// RenameAnalysisByteDiffSizeThreshold is the maximum size of each of the compared parts
	// to be diff-ed on byte level.
	RenameAnalysisByteDiffSizeThreshold = 100000
)
View Source
const (
	// DependencyTick is the name of the dependency which DaysSinceStart provides - the number
	// of ticks since the first commit in the analysed sequence.
	DependencyTick = "tick"

	// FactCommitsByTick contains the mapping between day indices and the corresponding commits.
	FactCommitsByTick = "TicksSinceStart.Commits"

	// FactTickSize contains the time.Duration of each tick.
	FactTickSize = "TicksSinceStart.TickSize"

	// ConfigTicksSinceStartTickSize sets the size of each 'tick' in hours.
	ConfigTicksSinceStartTickSize = "TicksSinceStart.TickSize"

	// DefaultTicksSinceStartTickSize is the default number of hours in each 'tick' (24*hour = 1day).
	DefaultTicksSinceStartTickSize = 24
)
View Source
const (
	// DependencyTreeChanges is the name of the dependency provided by TreeDiff.
	DependencyTreeChanges = "changes"
	// ConfigTreeDiffEnableBlacklist is the name of the configuration option
	// (TreeDiff.Configure()) which allows to skip blacklisted directories.
	ConfigTreeDiffEnableBlacklist = "TreeDiff.EnableBlacklist"
	// ConfigTreeDiffBlacklistedPrefixes s the name of the configuration option
	// (TreeDiff.Configure()) which allows to set blacklisted path prefixes -
	// directories or complete file names.
	ConfigTreeDiffBlacklistedPrefixes = "TreeDiff.BlacklistedPrefixes"
	// ConfigTreeDiffLanguages is the name of the configuration option (TreeDiff.Configure())
	// which sets the list of programming languages to analyze. Language names are at
	// https://doc.bblf.sh/languages.html Names are joined with a comma ",".
	// "all" is the special name which disables this filter.
	ConfigTreeDiffLanguages = "TreeDiff.LanguagesDetection"

	// ConfigTreeDiffFilterRegexp is the name of the configuration option
	// (TreeDiff.Configure()) which makes FileDiff consider only those files which have names matching this regexp.
	ConfigTreeDiffFilterRegexp = "TreeDiff.FilteredRegexes"
)
View Source
const (
	// DependencyLanguages is the name of the dependency provided by LanguagesDetection.
	DependencyLanguages = "languages"
)
View Source
const (
	// DependencyLineStats is the identifier of the data provided by LinesStatsCalculator - line
	// statistics for each file in the commit.
	DependencyLineStats = "line_stats"
)

Variables

View Source
var ErrorBinary = errors.New("binary")

ErrorBinary is raised in CachedBlob.CountLines() if the file is binary.

Functions

func DiffBytes

func DiffBytes(obuf, nbuf []byte) int

DiffBytes calculates the approximated number of different bytes between two binary buffers. We are not interested in the diff script itself. Instead, we track the sizes of `db` and `eb` from the original implementation.

func FloorTime added in v10.1.0

func FloorTime(t time.Time, d time.Duration) time.Time

FloorTime is the missing implementation of time.Time.Floor() - round to the nearest less than or equal.

Types

type BlobCache

type BlobCache struct {
	core.NoopMerger
	// Specifies how to handle the situation when we encounter a git submodule - an object
	// without the blob. If true, we look inside .gitmodules and if we don't find it,
	// raise an error. If false, we do not look inside .gitmodules and always succeed.
	FailOnMissingSubmodules bool
	// contains filtered or unexported fields
}

BlobCache loads the blobs which correspond to the changed files in a commit. It is a PipelineItem. It must provide the old and the new objects; "blobCache" rotates and allows to not load the same blobs twice. Outdated objects are removed so "blobCache" never grows big.

func (*BlobCache) Configure

func (blobCache *BlobCache) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*BlobCache) Consume

func (blobCache *BlobCache) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*BlobCache) Fork

func (blobCache *BlobCache) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*BlobCache) Initialize

func (blobCache *BlobCache) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*BlobCache) ListConfigurationOptions

func (blobCache *BlobCache) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*BlobCache) Name

func (blobCache *BlobCache) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*BlobCache) Provides

func (blobCache *BlobCache) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*BlobCache) Requires

func (blobCache *BlobCache) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type CachedBlob

type CachedBlob struct {
	object.Blob
	// Data is the read contents of the blob object.
	Data []byte
}

CachedBlob allows to explicitly cache the binary data associated with the Blob object.

func (*CachedBlob) Cache

func (b *CachedBlob) Cache() error

Cache reads the underlying blob object and sets CachedBlob.Data.

func (*CachedBlob) CountLines

func (b *CachedBlob) CountLines() (int, error)

CountLines returns the number of lines in the blob or (0, ErrorBinary) if it is binary.

func (*CachedBlob) Reader

func (b *CachedBlob) Reader() (io.ReadCloser, error)

Reader returns a reader allow the access to the content of the blob

type FileDiff

type FileDiff struct {
	core.NoopMerger
	CleanupDisabled  bool
	WhitespaceIgnore bool
	Timeout          time.Duration
	// contains filtered or unexported fields
}

FileDiff calculates the difference of files which were modified. It is a PipelineItem.

func (*FileDiff) Configure

func (diff *FileDiff) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*FileDiff) Consume

func (diff *FileDiff) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*FileDiff) Fork

func (diff *FileDiff) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*FileDiff) Initialize

func (diff *FileDiff) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*FileDiff) ListConfigurationOptions

func (diff *FileDiff) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*FileDiff) Name

func (diff *FileDiff) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*FileDiff) Provides

func (diff *FileDiff) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*FileDiff) Requires

func (diff *FileDiff) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type FileDiffData

type FileDiffData struct {
	OldLinesOfCode int
	NewLinesOfCode int
	Diffs          []diffmatchpatch.Diff
}

FileDiffData is the type of the dependency provided by FileDiff.

type FileGetter

type FileGetter func(path string) (*object.File, error)

FileGetter defines a function which loads the Git file by the specified path. The state can be arbitrary though here it always corresponds to the currently processed commit.

type LanguagesDetection

type LanguagesDetection struct {
	core.NoopMerger
	// contains filtered or unexported fields
}

LanguagesDetection run programming language detection over the changed files.

func (*LanguagesDetection) Configure

func (langs *LanguagesDetection) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*LanguagesDetection) Consume

func (langs *LanguagesDetection) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*LanguagesDetection) Fork

func (langs *LanguagesDetection) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*LanguagesDetection) Initialize

func (langs *LanguagesDetection) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*LanguagesDetection) ListConfigurationOptions

func (langs *LanguagesDetection) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*LanguagesDetection) Name

func (langs *LanguagesDetection) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*LanguagesDetection) Provides

func (langs *LanguagesDetection) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*LanguagesDetection) Requires

func (langs *LanguagesDetection) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type LineStats

type LineStats struct {
	// Added is the number of added lines by a particular developer in a particular day.
	Added int
	// Removed is the number of removed lines by a particular developer in a particular day.
	Removed int
	// Changed is the number of changed lines by a particular developer in a particular day.
	Changed int
}

LineStats holds the numbers of inserted, deleted and changed lines.

type LinesStatsCalculator

type LinesStatsCalculator struct {
	core.NoopMerger
	// contains filtered or unexported fields
}

LinesStatsCalculator measures line statistics for each text file in the commit.

func (*LinesStatsCalculator) Configure

func (lsc *LinesStatsCalculator) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*LinesStatsCalculator) Consume

func (lsc *LinesStatsCalculator) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*LinesStatsCalculator) Fork

func (lsc *LinesStatsCalculator) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*LinesStatsCalculator) Initialize

func (lsc *LinesStatsCalculator) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*LinesStatsCalculator) ListConfigurationOptions

func (lsc *LinesStatsCalculator) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*LinesStatsCalculator) Name

func (lsc *LinesStatsCalculator) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*LinesStatsCalculator) Provides

func (lsc *LinesStatsCalculator) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*LinesStatsCalculator) Requires

func (lsc *LinesStatsCalculator) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type RenameAnalysis

type RenameAnalysis struct {
	core.NoopMerger
	// SimilarityThreshold adjusts the heuristic to determine file renames.
	// It has the same units as cgit's -X rename-threshold or -M. Better to
	// set it to the default value of 80 (80%).
	SimilarityThreshold int

	// Timeout is the maximum time allowed to spend computing renames in a single commit.
	Timeout time.Duration
	// contains filtered or unexported fields
}

RenameAnalysis improves TreeDiff's results by searching for changed blobs under different paths which are likely to be the result of a rename with subsequent edits. RenameAnalysis is a PipelineItem.

func (*RenameAnalysis) Configure

func (ra *RenameAnalysis) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*RenameAnalysis) Consume

func (ra *RenameAnalysis) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*RenameAnalysis) Fork

func (ra *RenameAnalysis) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*RenameAnalysis) Initialize

func (ra *RenameAnalysis) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*RenameAnalysis) ListConfigurationOptions

func (ra *RenameAnalysis) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*RenameAnalysis) Name

func (ra *RenameAnalysis) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*RenameAnalysis) Provides

func (ra *RenameAnalysis) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*RenameAnalysis) Requires

func (ra *RenameAnalysis) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type TicksSinceStart

type TicksSinceStart struct {
	core.NoopMerger
	TickSize time.Duration
	// contains filtered or unexported fields
}

TicksSinceStart provides relative tick information for every commit. It is a PipelineItem.

func (*TicksSinceStart) Configure

func (ticks *TicksSinceStart) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*TicksSinceStart) Consume

func (ticks *TicksSinceStart) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*TicksSinceStart) Fork

func (ticks *TicksSinceStart) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*TicksSinceStart) Initialize

func (ticks *TicksSinceStart) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*TicksSinceStart) ListConfigurationOptions

func (ticks *TicksSinceStart) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*TicksSinceStart) Name

func (ticks *TicksSinceStart) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*TicksSinceStart) Provides

func (ticks *TicksSinceStart) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*TicksSinceStart) Requires

func (ticks *TicksSinceStart) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

type TreeDiff

type TreeDiff struct {
	core.NoopMerger
	SkipFiles  []string
	NameFilter *regexp.Regexp
	// Languages is the set of allowed languages. The values must be lower case. The default
	// (empty) set disables the language filter.
	Languages map[string]bool
	// contains filtered or unexported fields
}

TreeDiff generates the list of changes for a commit. A change can be either one or two blobs under the same path: "before" and "after". If "before" is nil, the change is an addition. If "after" is nil, the change is a removal. Otherwise, it is a modification. TreeDiff is a PipelineItem.

func (*TreeDiff) Configure

func (treediff *TreeDiff) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*TreeDiff) Consume

func (treediff *TreeDiff) Consume(deps map[string]interface{}) (map[string]interface{}, error)

Consume runs this PipelineItem on the next commit data. `deps` contain all the results from upstream PipelineItem-s as requested by Requires(). Additionally, DependencyCommit is always present there and represents the analysed *object.Commit. This function returns the mapping with analysis results. The keys must be the same as in Provides(). If there was an error, nil is returned.

func (*TreeDiff) Fork

func (treediff *TreeDiff) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*TreeDiff) Initialize

func (treediff *TreeDiff) Initialize(repository *git.Repository) error

Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume() calls. The repository which is going to be analysed is supplied as an argument.

func (*TreeDiff) ListConfigurationOptions

func (treediff *TreeDiff) ListConfigurationOptions() []core.ConfigurationOption

ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.

func (*TreeDiff) Name

func (treediff *TreeDiff) Name() string

Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

func (*TreeDiff) Provides

func (treediff *TreeDiff) Provides() []string

Provides returns the list of names of entities which are produced by this PipelineItem. Each produced entity will be inserted into `deps` of dependent Consume()-s according to this list. Also used by core.Registry to build the global map of providers.

func (*TreeDiff) Requires

func (treediff *TreeDiff) Requires() []string

Requires returns the list of names of entities which are needed by this PipelineItem. Each requested entity will be inserted into `deps` of Consume(). In turn, those entities are Provides() upstream.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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