Skip to content

Commit

Permalink
add since method for faster updating.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrala committed Jun 24, 2016
1 parent 1c85661 commit b9db0f4
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Helpers/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,30 @@ class Finder
*/
public function grep($repository, $grepArgument)
{
$process = new Process('git ls-tree -r --name-only HEAD | grep ' . ProcessUtils::escapeArgument($grepArgument));
$command = 'git ls-tree -r --name-only HEAD | grep ' . ProcessUtils::escapeArgument($grepArgument);
return $this->getCommandResult($repository, $command);
}

/**
* @param $repository
* @param $grepArgument
* @param string $since
* @return array
*/
public function grepTimed($repository, $grepArgument, $since = '1 day ago'){
// git whatchanged --since '24 day ago' --oneline --pretty=format: --name-only | grep Test.php
$command = 'git whatchanged --since \'' . $since . '\' --oneline --pretty=format: --name-only | grep ' . ProcessUtils::escapeArgument($grepArgument);
return $this->getCommandResult($repository, $command);
}

/**
* @param $repository
* @param $command
* @return array
*/
protected function getCommandResult($repository, $command)
{
$process = new Process($command);
$process->setWorkingDirectory($repository->getPath());
$process->run();
$output = trim($process->getOutput());
Expand Down

0 comments on commit b9db0f4

Please sign in to comment.