mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 05:22:16 +01:00
Switched short commit SHA to full SHA to remove ambiguity
This commit is contained in:
parent
0c5a055079
commit
58a8cca955
8 changed files with 45 additions and 18 deletions
|
@ -46,7 +46,7 @@ module GitStats
|
||||||
end
|
end
|
||||||
|
|
||||||
def commits
|
def commits
|
||||||
@commits ||= run_and_parse("git rev-list --pretty=format:'%h|%at|%ai|%aE' #{commit_range} #{tree_path} | grep -v commit").map do |commit_line|
|
@commits ||= run_and_parse("git rev-list --pretty=format:'%H|%at|%ai|%aE' #{commit_range} #{tree_path} | grep -v commit").map do |commit_line|
|
||||||
Commit.new(
|
Commit.new(
|
||||||
repo: self,
|
repo: self,
|
||||||
sha: commit_line[:sha],
|
sha: commit_line[:sha],
|
||||||
|
@ -116,7 +116,7 @@ module GitStats
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_version
|
def project_version
|
||||||
@project_version ||= run("git rev-parse --short #{commit_range}").strip
|
@project_version ||= run("git rev-parse #{commit_range}").strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_name
|
def project_name
|
||||||
|
|
|
@ -33,12 +33,12 @@ describe GitStats::GitData::Repo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should affect commits command' do
|
it 'should affect commits command' do
|
||||||
repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' abc..def . | grep -v commit").and_return("")
|
repo.should_receive(:run).with("git rev-list --pretty=format:'%H|%at|%ai|%aE' abc..def . | grep -v commit").and_return("")
|
||||||
repo.commits
|
repo.commits
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should affect project version command' do
|
it 'should affect project version command' do
|
||||||
repo.should_receive(:run).with('git rev-parse --short abc..def').and_return("")
|
repo.should_receive(:run).with('git rev-parse abc..def').and_return("")
|
||||||
repo.project_version
|
repo.project_version
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe GitStats::GitData::Repo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should parse git revlist output to date sorted commits array' do
|
it 'should parse git revlist output to date sorted commits array' do
|
||||||
repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD . | grep -v commit").and_return(
|
repo.should_receive(:run).with("git rev-list --pretty=format:'%H|%at|%ai|%aE' HEAD . | grep -v commit").and_return(
|
||||||
"e4412c3|1348603824|2012-09-25 22:10:24 +0200|john.doe@gmail.com
|
"e4412c3|1348603824|2012-09-25 22:10:24 +0200|john.doe@gmail.com
|
||||||
ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com
|
ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com
|
||||||
5eab339|1345835073|2012-08-24 21:04:33 +0200|john.doe@gmail.com
|
5eab339|1345835073|2012-08-24 21:04:33 +0200|john.doe@gmail.com
|
||||||
|
@ -39,7 +39,7 @@ ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
it 'should parse git rev-parse command to project version' do
|
it 'should parse git rev-parse command to project version' do
|
||||||
repo.should_receive(:run).with('git rev-parse --short HEAD').and_return('xyz')
|
repo.should_receive(:run).with('git rev-parse HEAD').and_return('xyz')
|
||||||
repo.project_version.should == 'xyz'
|
repo.project_version.should == 'xyz'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe GitStats::GitData::Tree do
|
||||||
|
|
||||||
it 'should parse git revlist output to date sorted commits array' do
|
it 'should parse git revlist output to date sorted commits array' do
|
||||||
repo_tree.should_receive(:run).
|
repo_tree.should_receive(:run).
|
||||||
with("git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD ./subdir_with_1_commit | grep -v commit").
|
with("git rev-list --pretty=format:'%H|%at|%ai|%aE' HEAD ./subdir_with_1_commit | grep -v commit").
|
||||||
and_return("10d1814|1395407506|2014-03-21 14:11:46 +0100|israelrevert@gmail.com")
|
and_return("10d1814|1395407506|2014-03-21 14:11:46 +0100|israelrevert@gmail.com")
|
||||||
repo_tree.commits.should ==
|
repo_tree.commits.should ==
|
||||||
[ GitStats::GitData::Commit.new( repo: repo, sha: "10d1814", stamp: "1395407506",
|
[ GitStats::GitData::Commit.new( repo: repo, sha: "10d1814", stamp: "1395407506",
|
||||||
|
|
|
@ -8,8 +8,17 @@ describe GitStats::GitData::Activity do
|
||||||
let(:jd) { repo.authors.first! { |a| a.email == 'john.doe@gmail.com' } }
|
let(:jd) { repo.authors.first! { |a| a.email == 'john.doe@gmail.com' } }
|
||||||
|
|
||||||
it 'should filter commits to author' do
|
it 'should filter commits to author' do
|
||||||
tg.commits.map(&:sha).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d 4e7d0e9 872955c)
|
tg.commits.map(&:sha).should =~ %w(
|
||||||
jd.commits.map(&:sha).should =~ %w(fd66657 81e8bef)
|
2c11f5e5224dd7d2fab27de0fca2a9a1d0ca4038
|
||||||
|
4e7d0e9e58e27e33d47f94faf4079a49a75931da
|
||||||
|
872955c3a6a4be4d7ae9b2dd4bea659979f0b457
|
||||||
|
ab47ef832c59837afcb626bfe22f0b8f0dc3717e
|
||||||
|
b3b4f819041eb66922abe79ee2513d5ddfb64691
|
||||||
|
b621a5df78e2953a040128191e47a24be9514b5c
|
||||||
|
c87ecf9c0bbdca29d73def8ed442cebf48178d92
|
||||||
|
d60b5eccf4513621bdbd65f408a0d28ff6fa9f5b
|
||||||
|
)
|
||||||
|
jd.commits.map(&:sha).should =~ %w(fd66657521139b1af6fde2927c4a383ecd6508fa 81e8bef75eaa93d772f2ce11d2a266ada1292741)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'activity' do
|
context 'activity' do
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe GitStats::GitData::Repo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should retrieve correct file content for old file' do
|
it 'should retrieve correct file content for old file' do
|
||||||
repo.commits.first! { |c| c.sha == 'c87ecf9' }.files.first! { |f| f.filename == 'test.txt' }.content.should == "bb
|
repo.commits.first! { |c| c.sha == 'c87ecf9c0bbdca29d73def8ed442cebf48178d92' }.files.first! { |f| f.filename == 'test.txt' }.content.should == "bb
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,18 @@ describe GitStats::GitData::Repo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should gather all commits sorted by date' do
|
it 'should gather all commits sorted by date' do
|
||||||
repo.commits.map(&:sha).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d fd66657 81e8bef 4e7d0e9 872955c)
|
repo.commits.map(&:sha).should =~ %w(
|
||||||
|
2c11f5e5224dd7d2fab27de0fca2a9a1d0ca4038
|
||||||
|
4e7d0e9e58e27e33d47f94faf4079a49a75931da
|
||||||
|
81e8bef75eaa93d772f2ce11d2a266ada1292741
|
||||||
|
872955c3a6a4be4d7ae9b2dd4bea659979f0b457
|
||||||
|
ab47ef832c59837afcb626bfe22f0b8f0dc3717e
|
||||||
|
b3b4f819041eb66922abe79ee2513d5ddfb64691
|
||||||
|
b621a5df78e2953a040128191e47a24be9514b5c
|
||||||
|
c87ecf9c0bbdca29d73def8ed442cebf48178d92
|
||||||
|
d60b5eccf4513621bdbd65f408a0d28ff6fa9f5b
|
||||||
|
fd66657521139b1af6fde2927c4a383ecd6508fa
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project name from dir' do
|
it 'should return project name from dir' do
|
||||||
|
@ -21,7 +32,7 @@ describe GitStats::GitData::Repo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project version as last commit hash' do
|
it 'should return project version as last commit hash' do
|
||||||
repo.project_version.should == '872955c'
|
repo.project_version.should == '872955c3a6a4be4d7ae9b2dd4bea659979f0b457'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should count files in repo' do
|
it 'should count files in repo' do
|
||||||
|
|
|
@ -14,7 +14,11 @@ describe GitStats::GitData::Tree do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should gather all commits sorted by date' do
|
it 'should gather all commits sorted by date' do
|
||||||
repo.commits.map(&:sha).should =~ %w(10d1814 435e0ef 5fd0f5e)
|
repo.commits.map(&:sha).should =~ %w(
|
||||||
|
10d1814b1c4acf1496ba76d40ee4954a2e3908fb
|
||||||
|
435e0ef41e7c4917e4ba635bb44c7d36c5c7b7ad
|
||||||
|
5fd0f5ea90e0ef34a0214ec9c170728913525ff4
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project name from dir' do
|
it 'should return project name from dir' do
|
||||||
|
@ -22,7 +26,7 @@ describe GitStats::GitData::Tree do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project version as last commit hash' do
|
it 'should return project version as last commit hash' do
|
||||||
repo.project_version.should == '5fd0f5e'
|
repo.project_version.should == '5fd0f5ea90e0ef34a0214ec9c170728913525ff4'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should count files in repo' do
|
it 'should count files in repo' do
|
||||||
|
@ -79,7 +83,7 @@ describe GitStats::GitData::Tree do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should gather all commits sorted by date' do
|
it 'should gather all commits sorted by date' do
|
||||||
repo.commits.map(&:sha).should =~ %w(10d1814)
|
repo.commits.map(&:sha).should =~ %w(10d1814b1c4acf1496ba76d40ee4954a2e3908fb)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project name from dir' do
|
it 'should return project name from dir' do
|
||||||
|
@ -87,7 +91,7 @@ describe GitStats::GitData::Tree do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project version as last commit hash' do
|
it 'should return project version as last commit hash' do
|
||||||
repo.project_version.should == '5fd0f5e'
|
repo.project_version.should == '5fd0f5ea90e0ef34a0214ec9c170728913525ff4'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should count files in repo' do
|
it 'should count files in repo' do
|
||||||
|
@ -144,7 +148,10 @@ describe GitStats::GitData::Tree do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should gather all commits sorted by date' do
|
it 'should gather all commits sorted by date' do
|
||||||
repo.commits.map(&:sha).should =~ %w(435e0ef 5fd0f5e)
|
repo.commits.map(&:sha).should =~ %w(
|
||||||
|
435e0ef41e7c4917e4ba635bb44c7d36c5c7b7ad
|
||||||
|
5fd0f5ea90e0ef34a0214ec9c170728913525ff4
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project name from dir' do
|
it 'should return project name from dir' do
|
||||||
|
@ -152,7 +159,7 @@ describe GitStats::GitData::Tree do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return project version as last commit hash' do
|
it 'should return project version as last commit hash' do
|
||||||
repo.project_version.should == '5fd0f5e'
|
repo.project_version.should == '5fd0f5ea90e0ef34a0214ec9c170728913525ff4'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should count files in repo' do
|
it 'should count files in repo' do
|
||||||
|
|
Loading…
Reference in a new issue