Skip to content

Commit

Permalink
Merge pull request #30 from mikechernev/bugfix/lint-staged-files-only
Browse files Browse the repository at this point in the history
Check only the files that are staged for commit
  • Loading branch information
veewee committed Aug 17, 2015
2 parents b6eabaa + 8d5eb13 commit 72a8b80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions spec/GrumPHP/Locator/ChangedFilesSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Gitonomy\Git\Diff\Diff;
use Gitonomy\Git\Diff\File;
use Gitonomy\Git\WorkingCopy;
use Gitonomy\Git\Repository;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
Expand Down Expand Up @@ -37,13 +38,14 @@ protected function mockFile($name, $isRename = false, $isDelete = false)
return $file->reveal();
}

function it_will_list_all_diffed_files(Repository $repository, Diff $diff)
function it_will_list_all_diffed_files(Repository $repository, Diff $diff, WorkingCopy $workingCopy)
{
$changedFile = $this->mockFile('file1.txt');
$movedFile = $this->mockFile('file2.txt', true);
$deletedFile = $this->mockFile('file3.txt', false, true);

$repository->getDiff('HEAD')->willReturn($diff);
$repository->getWorkingCopy()->willReturn($workingCopy);
$workingCopy->getDiffStaged()->willReturn($diff);
$diff->getFiles()->willReturn(array($changedFile, $movedFile, $deletedFile));

$result = $this->locate();
Expand Down
2 changes: 1 addition & 1 deletion src/GrumPHP/Locator/ChangedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(Repository $repository)
*/
public function locate()
{
$diff = $this->repository->getDiff('HEAD');
$diff = $this->repository->getWorkingCopy()->getDiffStaged();
$files = array();
/** @var File $file */
foreach ($diff->getFiles() as $file) {
Expand Down

0 comments on commit 72a8b80

Please sign in to comment.