class Linguist::Repository

Overview

A Repository is an abstraction of a Grit::Repo or a basic file system tree. It holds a list of paths pointing to Blobish objects.

Its primary purpose is for gathering language statistics across the entire project.

Defined in:

linguist/repository.cr

Constant Summary

MAX_TREE_SIZE = 100000

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(repo : Git::Repository, commit_oid : Git::Oid | String) #

Public: Initialize a new Repository to be analyzed for language data

repo - a Rugged::Repository object commit_oid - the sha1 of the commit that will be analyzed; this is usually the master branch

Returns a Repository


[View source]

Class Method Detail

def self.incremental(repo, commit_oid, old_commit_oid, old_stats) #

Public: Create a new Repository based on the stats of an existing one


[View source]

Instance Method Detail

def breakdown_by_file #

Public: Return the language breakdown of this repository by file

Returns a map of language names => [filenames...]


[View source]
def cache #

Public: Return the cached results of the analysis

This is a per-file breakdown that can be passed to other instances of Linguist::Repository to perform incremental scans

Returns a map of filename => [language, size]


[View source]
def compute_stats(old_commit_oid, cache = nil) #

[View source]
def current_tree #

[View source]
def detector(blob, name) #

[View source]
def get_first_commit #

[View source]
def language #

Public: Get primary Language of repository.

Returns a language name


[View source]
def languages #

Public: Returns a breakdown of language stats.

Examples

=> { 'Ruby' => 46319,

     'JavaScript' => 258 }

Returns a Hash of language names and Integer size values.


[View source]
def load_existing_stats(old_commit_oid : Git::Oid | String, old_stats : Nil | Hash(String, Tuple(Nil | ::Linguist::Language, Int32 | Int64))) #

Public: Load the results of a previous analysis on this repository to speed up the new scan.

The new analysis will be performed incrementally as to only take into account the file changes since the last time the repository was scanned

old_commit_oid - the sha1 of the commit that was previously analyzed old_stats - the result of the previous analysis, obtained by calling Repository#cache on the old repository

Returns nothing


[View source]
def repository : Git::Repository #

[View source]
def size : Int32 #

Public: Get the total size of the repository.

Returns a byte size Integer


[View source]