Skip to content

Commit

Permalink
Fix symfony 4 ProcessUtils::escapeArgument removal
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrala committed Oct 1, 2018
1 parent e2c0062 commit 996c9e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: php
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'

install:
- composer install
- composer install
16 changes: 8 additions & 8 deletions src/Helpers/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ class Finder
*/
public function grep($repository, $grepArgument)
{
$command = 'git ls-tree -r --name-only HEAD | grep ' . ProcessUtils::escapeArgument($grepArgument);
return $this->getCommandResult($repository, $command);
$command = 'git ls-tree -r --name-only HEAD | grep $GREPARG';
return $this->getCommandResult($repository, $command, ['GREPARG' => $grepArgument]);
}

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

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

0 comments on commit 996c9e9

Please sign in to comment.