diff --git a/src/Helpers/Finder.php b/src/Helpers/Finder.php index 15e4480..afba066 100644 --- a/src/Helpers/Finder.php +++ b/src/Helpers/Finder.php @@ -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());