Documentation ¶
Index ¶
- Constants
- Variables
- func DiffBytes(obuf, nbuf []byte) int
- type BlobCache
- func (blobCache *BlobCache) Configure(facts map[string]interface{}) error
- func (blobCache *BlobCache) Consume(deps map[string]interface{}) (map[string]interface{}, error)
- func (blobCache *BlobCache) Fork(n int) []core.PipelineItem
- func (blobCache *BlobCache) Initialize(repository *git.Repository) error
- func (blobCache *BlobCache) ListConfigurationOptions() []core.ConfigurationOption
- func (blobCache *BlobCache) Name() string
- func (blobCache *BlobCache) Provides() []string
- func (blobCache *BlobCache) Requires() []string
- type CachedBlob
- type DaysSinceStart
- func (days *DaysSinceStart) Configure(facts map[string]interface{}) error
- func (days *DaysSinceStart) Consume(deps map[string]interface{}) (map[string]interface{}, error)
- func (days *DaysSinceStart) Fork(n int) []core.PipelineItem
- func (days *DaysSinceStart) Initialize(repository *git.Repository) error
- func (days *DaysSinceStart) ListConfigurationOptions() []core.ConfigurationOption
- func (days *DaysSinceStart) Name() string
- func (days *DaysSinceStart) Provides() []string
- func (days *DaysSinceStart) Requires() []string
- type FileDiff
- func (diff *FileDiff) Configure(facts map[string]interface{}) error
- func (diff *FileDiff) Consume(deps map[string]interface{}) (map[string]interface{}, error)
- func (diff *FileDiff) Fork(n int) []core.PipelineItem
- func (diff *FileDiff) Initialize(repository *git.Repository) error
- func (diff *FileDiff) ListConfigurationOptions() []core.ConfigurationOption
- func (diff *FileDiff) Name() string
- func (diff *FileDiff) Provides() []string
- func (diff *FileDiff) Requires() []string
- type FileDiffData
- type FileGetter
- type LanguagesDetection
- func (langs *LanguagesDetection) Configure(facts map[string]interface{}) error
- func (langs *LanguagesDetection) Consume(deps map[string]interface{}) (map[string]interface{}, error)
- func (langs *LanguagesDetection) Fork(n int) []core.PipelineItem
- func (langs *LanguagesDetection) Initialize(repository *git.Repository) error
- func (langs *LanguagesDetection) ListConfigurationOptions() []core.ConfigurationOption
- func (langs *LanguagesDetection) Name() string
- func (langs *LanguagesDetection) Provides() []string
- func (langs *LanguagesDetection) Requires() []string
- type LevenshteinContext
- type RenameAnalysis
- func (ra *RenameAnalysis) Configure(facts map[string]interface{}) error
- func (ra *RenameAnalysis) Consume(deps map[string]interface{}) (map[string]interface{}, error)
- func (ra *RenameAnalysis) Fork(n int) []core.PipelineItem
- func (ra *RenameAnalysis) Initialize(repository *git.Repository) error
- func (ra *RenameAnalysis) ListConfigurationOptions() []core.ConfigurationOption
- func (ra *RenameAnalysis) Name() string
- func (ra *RenameAnalysis) Provides() []string
- func (ra *RenameAnalysis) Requires() []string
- type TreeDiff
- func (treediff *TreeDiff) Configure(facts map[string]interface{}) error
- func (treediff *TreeDiff) Consume(deps map[string]interface{}) (map[string]interface{}, error)
- func (treediff *TreeDiff) Fork(n int) []core.PipelineItem
- func (treediff *TreeDiff) Initialize(repository *git.Repository) error
- func (treediff *TreeDiff) ListConfigurationOptions() []core.ConfigurationOption
- func (treediff *TreeDiff) Name() string
- func (treediff *TreeDiff) Provides() []string
- func (treediff *TreeDiff) Requires() []string
Constants ¶
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" )
const ( // DependencyDay is the name of the dependency which DaysSinceStart provides - the number // of days since the first commit in the analysed sequence. DependencyDay = "day" // FactCommitsByDay contains the mapping between day indices and the corresponding commits. FactCommitsByDay = "DaysSinceStart.Commits" )
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" )
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 // ConfigRenameAnalysisSimilarityThreshold is the name of the configuration option // (RenameAnalysis.Configure()) which sets the similarity threshold. ConfigRenameAnalysisSimilarityThreshold = "RenameAnalysis.SimilarityThreshold" // 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 )
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" )
const (
// DependencyLanguages is the name of the dependency provided by LanguagesDetection.
DependencyLanguages = "languages"
)
Variables ¶
var ErrorBinary = errors.New("binary")
ErrorBinary is raised in CachedBlob.CountLines() if the file is binary.
Functions ¶
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 ¶
Configure sets the properties previously published by ListConfigurationOptions().
func (*BlobCache) Consume ¶
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 ¶
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 ¶
Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.
type CachedBlob ¶
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 DaysSinceStart ¶
type DaysSinceStart struct { core.NoopMerger // contains filtered or unexported fields }
DaysSinceStart provides the relative date information for every commit. It is a PipelineItem.
func (*DaysSinceStart) Configure ¶
func (days *DaysSinceStart) Configure(facts map[string]interface{}) error
Configure sets the properties previously published by ListConfigurationOptions().
func (*DaysSinceStart) Consume ¶
func (days *DaysSinceStart) 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 (*DaysSinceStart) Fork ¶
func (days *DaysSinceStart) Fork(n int) []core.PipelineItem
Fork clones this PipelineItem.
func (*DaysSinceStart) Initialize ¶
func (days *DaysSinceStart) 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 (*DaysSinceStart) ListConfigurationOptions ¶
func (days *DaysSinceStart) ListConfigurationOptions() []core.ConfigurationOption
ListConfigurationOptions returns the list of changeable public properties of this PipelineItem.
func (*DaysSinceStart) Name ¶
func (days *DaysSinceStart) Name() string
Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.
func (*DaysSinceStart) Provides ¶
func (days *DaysSinceStart) 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 (*DaysSinceStart) Requires ¶
func (days *DaysSinceStart) 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 FileDiff ¶
type FileDiff struct { core.NoopMerger CleanupDisabled bool WhitespaceIgnore bool }
FileDiff calculates the difference of files which were modified. It is a PipelineItem.
func (*FileDiff) Configure ¶
Configure sets the properties previously published by ListConfigurationOptions().
func (*FileDiff) Consume ¶
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 ¶
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 ¶
Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.
type FileDiffData ¶
type FileDiffData struct { OldLinesOfCode int NewLinesOfCode int Diffs []diffmatchpatch.Diff }
FileDiffData is the type of the dependency provided by FileDiff.
type FileGetter ¶
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
}
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 LevenshteinContext ¶
type LevenshteinContext struct {
// contains filtered or unexported fields
}
LevenshteinContext is the object which allows to calculate the Levenshtein distance with Distance() method. It is needed to ensure 0 memory allocations.
func (*LevenshteinContext) Distance ¶
func (c *LevenshteinContext) Distance(str1, str2 string) int
Distance calculates the Levenshtein distance between two strings which is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character http://en.wikipedia.org/wiki/Levenshtein_distance
This implementation is optimized to use O(min(m,n)) space. It is based on the optimized C version found here: http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#C
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 // 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 TreeDiff ¶
type TreeDiff struct { core.NoopMerger SkipFiles []string NameFilter *regexp.Regexp 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 ¶
Configure sets the properties previously published by ListConfigurationOptions().
func (*TreeDiff) Consume ¶
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 ¶
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 ¶
Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.