mirror of https://github.com/tomgi/git_stats.git
testing file content gathering
This commit is contained in:
parent
4dc5165505
commit
a4f650b760
|
@ -10,7 +10,7 @@ module GitStats
|
|||
def files
|
||||
@files ||= repo.run_and_parse("git ls-tree -r #{self.hash}").map do |file|
|
||||
Blob.new(repo: repo, filename: file[:filename], hash: file[:hash])
|
||||
end
|
||||
end.extend(ByFieldFinder)
|
||||
end
|
||||
|
||||
def files_by_extension
|
||||
|
|
|
@ -27,7 +27,7 @@ module GitStats
|
|||
|
||||
date = DateTime.parse(date)
|
||||
Commit.new(repo: self, hash: hash, stamp: stamp, date: date, author: author)
|
||||
end.sort_by! { |e| e.date }
|
||||
end.sort_by! { |e| e.date }.extend(ByFieldFinder)
|
||||
end
|
||||
|
||||
def last_commit
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Activity do
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '45677ee') }
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '872955c') }
|
||||
let(:activity) { repo.activity }
|
||||
|
||||
it 'should count commits by hour' do
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Activity do
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '45677ee') }
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '872955c') }
|
||||
|
||||
let(:tg) { repo.authors.by_email('tomasz.gieniusz@gmail.com') }
|
||||
let(:jd) { repo.authors.by_email('john.doe@gmail.com') }
|
||||
|
||||
it 'should filter commits to author' do
|
||||
tg.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d 4e7d0e9 45677ee)
|
||||
tg.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d 4e7d0e9 872955c)
|
||||
jd.commits.map(&:hash).should =~ %w(fd66657 81e8bef)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Repo do
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '872955c') }
|
||||
|
||||
it 'should gather all files in repo' do
|
||||
repo.files.map(&:filename).should =~ %w(long_second.haml long.txt second.txt test2.rb test.rb test.txt)
|
||||
end
|
||||
|
||||
it 'should retrieve correct file content for old file' do
|
||||
repo.commits.by_hash('c87ecf9').files.by_filename('test.txt').content.should == "bb
|
||||
|
||||
|
||||
|
||||
test
|
||||
"
|
||||
end
|
||||
|
||||
it 'should retrieve correct file content for the newest file' do
|
||||
file = repo.files.by_filename('test.txt')
|
||||
file.content.should == "bb
|
||||
|
||||
testtest
|
||||
|
||||
test
|
||||
"
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitStats::GitData::Repo do
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '45677ee') }
|
||||
let(:repo) { build(:test_repo, last_commit_hash: '872955c') }
|
||||
|
||||
it 'should gather all authors' do
|
||||
repo.authors.should =~ [
|
||||
|
@ -11,7 +11,7 @@ describe GitStats::GitData::Repo do
|
|||
end
|
||||
|
||||
it 'should gather all commits sorted by date' do
|
||||
repo.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d fd66657 81e8bef 4e7d0e9 45677ee)
|
||||
repo.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d fd66657 81e8bef 4e7d0e9 872955c)
|
||||
end
|
||||
|
||||
it 'should return project name from dir' do
|
||||
|
@ -19,7 +19,7 @@ describe GitStats::GitData::Repo do
|
|||
end
|
||||
|
||||
it 'should return project version as last commit hash' do
|
||||
repo.project_version.should == '45677ee'
|
||||
repo.project_version.should == '872955c'
|
||||
end
|
||||
|
||||
it 'should count files in repo' do
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 45677ee1ececcf2e8eab452f8af2c7a3e30e65d9
|
||||
Subproject commit 872955c3a6a4be4d7ae9b2dd4bea659979f0b457
|
Loading…
Reference in New Issue