Skip to content

Commit

Permalink
Merge pull request #21 from DaveLiddament/fix/diff-reference-point
Browse files Browse the repository at this point in the history
FIX compare baseline against current code NOT most recent commit.
  • Loading branch information
DaveLiddament authored Dec 30, 2018
2 parents 7693d38 + da8dc9b commit 1e9e05a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/Plugins/GitDiffHistoryAnalyser/GitDiffHistoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function newHistoryAnalyser(HistoryMarker $baseLineHistoryMarker, Project
{
/** @var GitCommit $baseLineHistoryMarker */
Assert::isInstanceOf($baseLineHistoryMarker, GitCommit::class);
$newDiff = $this->gitCliWrapper->getCurrentSha($projectRoot);
$diff = $this->gitCliWrapper->getGitDiff($projectRoot, $baseLineHistoryMarker, $newDiff);
$diff = $this->gitCliWrapper->getGitDiff($projectRoot, $baseLineHistoryMarker);
$fileMutations = $this->parser->parseDiff($diff);

return new DiffHistoryAnalyser($fileMutations);
Expand Down
7 changes: 3 additions & 4 deletions src/Plugins/GitDiffHistoryAnalyser/internal/GitCliWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ public function getCurrentSha(ProjectRoot $projectRoot): GitCommit
/**
* {@inheritdoc}
*/
public function getGitDiff(ProjectRoot $projectRoot, GitCommit $originalCommit, GitCommit $newCommit): string
public function getGitDiff(ProjectRoot $projectRoot, GitCommit $originalCommit): string
{
$range = sprintf('%s..%s', $originalCommit->asString(), $newCommit->asString());
$arguments = [
'diff',
'-w',
'-M',
$range,
$originalCommit->asString(),
];
$command = $this->getGitCommand($arguments, $projectRoot);

Expand Down Expand Up @@ -83,7 +82,7 @@ private function getGitCommand(array $arguments, ProjectRoot $projectRoot): arra
{
$gitCommand = [
'git',
"--git-dir={$projectRoot}/.git",
'--git-dir='.$projectRoot.\DIRECTORY_SEPARATOR.'.git',
"--work-tree={$projectRoot}",
];

Expand Down
3 changes: 1 addition & 2 deletions src/Plugins/GitDiffHistoryAnalyser/internal/GitWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public function getCurrentSha(ProjectRoot $projectRoot): GitCommit;
*
* @param ProjectRoot $projectRoot
* @param GitCommit $originalCommit
* @param GitCommit $newCommit
*
* @return string
*/
public function getGitDiff(ProjectRoot $projectRoot, GitCommit $originalCommit, GitCommit $newCommit): string;
public function getGitDiff(ProjectRoot $projectRoot, GitCommit $originalCommit): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getCurrentSha(ProjectRoot $projectRoot): GitCommit
/**
* {@inheritdoc}
*/
public function getGitDiff(ProjectRoot $projectRoot, GitCommit $originalCommit, GitCommit $newCommit): string
public function getGitDiff(ProjectRoot $projectRoot, GitCommit $originalCommit): string
{
return $this->diff;
}
Expand Down

0 comments on commit 1e9e05a

Please sign in to comment.