From 58a8cca955cd8818d783f982d883e594e85f6ddb Mon Sep 17 00:00:00 2001 From: Tomasz Gieniusz Date: Fri, 1 Dec 2017 11:39:51 +0100 Subject: [PATCH] Switched short commit SHA to full SHA to remove ambiguity --- lib/git_stats/git_data/repo.rb | 4 ++-- spec/git_data/commit_range_spec.rb | 4 ++-- spec/git_data/repo_spec.rb | 4 ++-- spec/git_data/tree_spec.rb | 2 +- spec/integration/author_spec.rb | 13 +++++++++++-- spec/integration/file_spec.rb | 2 +- spec/integration/repo_spec.rb | 15 +++++++++++++-- spec/integration/tree_spec.rb | 19 +++++++++++++------ 8 files changed, 45 insertions(+), 18 deletions(-) diff --git a/lib/git_stats/git_data/repo.rb b/lib/git_stats/git_data/repo.rb index 5fd2440f3..a9eb67098 100644 --- a/lib/git_stats/git_data/repo.rb +++ b/lib/git_stats/git_data/repo.rb @@ -46,7 +46,7 @@ module GitStats end 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( repo: self, sha: commit_line[:sha], @@ -116,7 +116,7 @@ module GitStats end def project_version - @project_version ||= run("git rev-parse --short #{commit_range}").strip + @project_version ||= run("git rev-parse #{commit_range}").strip end def project_name diff --git a/spec/git_data/commit_range_spec.rb b/spec/git_data/commit_range_spec.rb index b4096795b..6960b07ca 100644 --- a/spec/git_data/commit_range_spec.rb +++ b/spec/git_data/commit_range_spec.rb @@ -33,12 +33,12 @@ describe GitStats::GitData::Repo do end 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 end 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 end end diff --git a/spec/git_data/repo_spec.rb b/spec/git_data/repo_spec.rb index b9f49d61b..fb43bd897 100644 --- a/spec/git_data/repo_spec.rb +++ b/spec/git_data/repo_spec.rb @@ -19,7 +19,7 @@ describe GitStats::GitData::Repo do end 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 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 @@ -39,7 +39,7 @@ ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com end end 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' end end diff --git a/spec/git_data/tree_spec.rb b/spec/git_data/tree_spec.rb index 477a639fd..10a1df168 100644 --- a/spec/git_data/tree_spec.rb +++ b/spec/git_data/tree_spec.rb @@ -29,7 +29,7 @@ describe GitStats::GitData::Tree do it 'should parse git revlist output to date sorted commits array' do 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") repo_tree.commits.should == [ GitStats::GitData::Commit.new( repo: repo, sha: "10d1814", stamp: "1395407506", diff --git a/spec/integration/author_spec.rb b/spec/integration/author_spec.rb index 229d0e8ab..f644f4ce6 100644 --- a/spec/integration/author_spec.rb +++ b/spec/integration/author_spec.rb @@ -8,8 +8,17 @@ describe GitStats::GitData::Activity do let(:jd) { repo.authors.first! { |a| a.email == 'john.doe@gmail.com' } } it 'should filter commits to author' do - tg.commits.map(&:sha).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d 4e7d0e9 872955c) - jd.commits.map(&:sha).should =~ %w(fd66657 81e8bef) + tg.commits.map(&:sha).should =~ %w( + 2c11f5e5224dd7d2fab27de0fca2a9a1d0ca4038 + 4e7d0e9e58e27e33d47f94faf4079a49a75931da + 872955c3a6a4be4d7ae9b2dd4bea659979f0b457 + ab47ef832c59837afcb626bfe22f0b8f0dc3717e + b3b4f819041eb66922abe79ee2513d5ddfb64691 + b621a5df78e2953a040128191e47a24be9514b5c + c87ecf9c0bbdca29d73def8ed442cebf48178d92 + d60b5eccf4513621bdbd65f408a0d28ff6fa9f5b + ) + jd.commits.map(&:sha).should =~ %w(fd66657521139b1af6fde2927c4a383ecd6508fa 81e8bef75eaa93d772f2ce11d2a266ada1292741) end context 'activity' do diff --git a/spec/integration/file_spec.rb b/spec/integration/file_spec.rb index d43a13d4f..2e955b052 100644 --- a/spec/integration/file_spec.rb +++ b/spec/integration/file_spec.rb @@ -9,7 +9,7 @@ describe GitStats::GitData::Repo do end 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 diff --git a/spec/integration/repo_spec.rb b/spec/integration/repo_spec.rb index 20fbf55b2..82358411d 100644 --- a/spec/integration/repo_spec.rb +++ b/spec/integration/repo_spec.rb @@ -13,7 +13,18 @@ describe GitStats::GitData::Repo do end 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 it 'should return project name from dir' do @@ -21,7 +32,7 @@ describe GitStats::GitData::Repo do end it 'should return project version as last commit hash' do - repo.project_version.should == '872955c' + repo.project_version.should == '872955c3a6a4be4d7ae9b2dd4bea659979f0b457' end it 'should count files in repo' do diff --git a/spec/integration/tree_spec.rb b/spec/integration/tree_spec.rb index bbb740aef..66d0435ad 100644 --- a/spec/integration/tree_spec.rb +++ b/spec/integration/tree_spec.rb @@ -14,7 +14,11 @@ describe GitStats::GitData::Tree do end 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 it 'should return project name from dir' do @@ -22,7 +26,7 @@ describe GitStats::GitData::Tree do end it 'should return project version as last commit hash' do - repo.project_version.should == '5fd0f5e' + repo.project_version.should == '5fd0f5ea90e0ef34a0214ec9c170728913525ff4' end it 'should count files in repo' do @@ -79,7 +83,7 @@ describe GitStats::GitData::Tree do end it 'should gather all commits sorted by date' do - repo.commits.map(&:sha).should =~ %w(10d1814) + repo.commits.map(&:sha).should =~ %w(10d1814b1c4acf1496ba76d40ee4954a2e3908fb) end it 'should return project name from dir' do @@ -87,7 +91,7 @@ describe GitStats::GitData::Tree do end it 'should return project version as last commit hash' do - repo.project_version.should == '5fd0f5e' + repo.project_version.should == '5fd0f5ea90e0ef34a0214ec9c170728913525ff4' end it 'should count files in repo' do @@ -144,7 +148,10 @@ describe GitStats::GitData::Tree do end 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 it 'should return project name from dir' do @@ -152,7 +159,7 @@ describe GitStats::GitData::Tree do end it 'should return project version as last commit hash' do - repo.project_version.should == '5fd0f5e' + repo.project_version.should == '5fd0f5ea90e0ef34a0214ec9c170728913525ff4' end it 'should count files in repo' do