hercules.v9: gopkg.in/src-d/hercules.v9/internal/plumbing Index | Files | Directories

package plumbing

import "gopkg.in/src-d/hercules.v9/internal/plumbing"

Index

Package Files

blob_cache.go bsdiff.go day.go diff.go languages.go line_stats.go renames.go tree_diff.go

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"
)
const (
    // DependencyLineStats is the identifier of the data provided by LinesStatsCalculator - line
    // statistics for each file in the commit.
    DependencyLineStats = "line_stats"
)

Variables

var ErrorBinary = errors.New("binary")

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

func DiffBytes Uses

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.

type BlobCache Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*BlobCache) Consume Uses

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 Uses

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

Fork clones this PipelineItem.

func (*BlobCache) Initialize Uses

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 Uses

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

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

func (*BlobCache) Name Uses

func (blobCache *BlobCache) Name() string

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

func (*BlobCache) Provides Uses

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 Uses

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 Uses

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 Uses

func (b *CachedBlob) Cache() error

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

func (*CachedBlob) CountLines Uses

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 Uses

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

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

type DaysSinceStart Uses

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 Uses

func (days *DaysSinceStart) Configure(facts map[string]interface{}) error

Configure sets the properties previously published by ListConfigurationOptions().

func (*DaysSinceStart) Consume Uses

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 Uses

func (days *DaysSinceStart) Fork(n int) []core.PipelineItem

Fork clones this PipelineItem.

func (*DaysSinceStart) Initialize Uses

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 Uses

func (days *DaysSinceStart) ListConfigurationOptions() []core.ConfigurationOption

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

func (*DaysSinceStart) Name Uses

func (days *DaysSinceStart) Name() string

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

func (*DaysSinceStart) Provides Uses

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 Uses

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 Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*FileDiff) Consume Uses

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 Uses

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

Fork clones this PipelineItem.

func (*FileDiff) Initialize Uses

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 Uses

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

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

func (*FileDiff) Name Uses

func (diff *FileDiff) Name() string

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

func (*FileDiff) Provides Uses

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 Uses

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 Uses

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

FileDiffData is the type of the dependency provided by FileDiff.

type FileGetter Uses

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 Uses

type LanguagesDetection struct {
    core.NoopMerger
}

LanguagesDetection run programming language detection over the changed files.

func (*LanguagesDetection) Configure Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*LanguagesDetection) Consume Uses

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 Uses

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

Fork clones this PipelineItem.

func (*LanguagesDetection) Initialize Uses

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 Uses

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

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

func (*LanguagesDetection) Name Uses

func (langs *LanguagesDetection) Name() string

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

func (*LanguagesDetection) Provides Uses

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 Uses

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 Uses

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 Uses

type LinesStatsCalculator struct {
    core.NoopMerger
}

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

func (*LinesStatsCalculator) Configure Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*LinesStatsCalculator) Consume Uses

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 Uses

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

Fork clones this PipelineItem.

func (*LinesStatsCalculator) Initialize Uses

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 Uses

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

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

func (*LinesStatsCalculator) Name Uses

func (lsc *LinesStatsCalculator) Name() string

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

func (*LinesStatsCalculator) Provides Uses

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 Uses

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 Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*RenameAnalysis) Consume Uses

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 Uses

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

Fork clones this PipelineItem.

func (*RenameAnalysis) Initialize Uses

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 Uses

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

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

func (*RenameAnalysis) Name Uses

func (ra *RenameAnalysis) Name() string

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

func (*RenameAnalysis) Provides Uses

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 Uses

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 Uses

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 Uses

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

Configure sets the properties previously published by ListConfigurationOptions().

func (*TreeDiff) Consume Uses

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 Uses

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

Fork clones this PipelineItem.

func (*TreeDiff) Initialize Uses

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 Uses

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

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

func (*TreeDiff) Name Uses

func (treediff *TreeDiff) Name() string

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

func (*TreeDiff) Provides Uses

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 Uses

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

PathSynopsis
identity
uast
uast/test

Package plumbing imports 24 packages (graph) and is imported by 5 packages. Updated 2019-04-26. Refresh now. Tools for package owners.