From b9db0f46d9d309a7bbd2dc1e75680879af910707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brala?= Date: Fri, 24 Jun 2016 13:11:49 +0200 Subject: [PATCH] add since method for faster updating. --- src/Helpers/Finder.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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());