mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Bust that cache
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
require 'linguist/lazy_blob'
|
||||
require 'rugged'
|
||||
|
||||
require 'pry'
|
||||
module Linguist
|
||||
# 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.
|
||||
@@ -128,13 +128,23 @@ module Linguist
|
||||
protected
|
||||
|
||||
def compute_stats(old_commit_oid, cache = nil)
|
||||
file_map = cache ? cache.dup : {}
|
||||
old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree
|
||||
|
||||
read_index
|
||||
|
||||
diff = Rugged::Tree.diff(repository, old_tree, current_tree)
|
||||
|
||||
# Clear file map and fetch full diff if any .gitattributes files are changed
|
||||
if cache && diff.each_delta.any? { |delta| File.basename(delta.new_file[:path]) == ".gitattributes" }
|
||||
diff = Rugged::Tree.diff(repository, old_tree = nil, current_tree)
|
||||
file_map = {}
|
||||
else
|
||||
file_map = cache ? cache.dup : {}
|
||||
end
|
||||
|
||||
# TODO - do we need to re-read the index?
|
||||
# read_index
|
||||
|
||||
diff.each_delta do |delta|
|
||||
old = delta.old_file[:path]
|
||||
new = delta.new_file[:path]
|
||||
|
||||
@@ -68,6 +68,18 @@ class TestRepository < Test::Unit::TestCase
|
||||
assert !repo.breakdown_by_file["Ruby"].empty?
|
||||
end
|
||||
|
||||
def test_commit_with_git_attributes_data
|
||||
old_commit = '3d7364877d6794f6cc2a86b493e893968a597332'
|
||||
old_repo = linguist_repo(old_commit)
|
||||
|
||||
attr_commit = '7ee006cbcb2d7261f9e648510a684ee9ac64126b'
|
||||
new_repo = Linguist::Repository.incremental(rugged_repository, attr_commit, old_commit, old_repo.cache)
|
||||
|
||||
Rugged::Tree.expects(:diff).twice
|
||||
|
||||
new_repo.send(:compute_stats, old_commit, old_repo.cache)
|
||||
end
|
||||
|
||||
def test_linguist_override_vendored?
|
||||
attr_commit = '351c1cc8fd57340839bdb400d7812332af80e9bd'
|
||||
repo = linguist_repo(attr_commit).read_index
|
||||
|
||||
Reference in New Issue
Block a user