PHPComposter\PHPComposter\BaseAction::getStagedFiles PHP Method

getStagedFiles() protected method

Get the file sthat have been staged for the current commit.
Since: 0.1.3
protected getStagedFiles ( $pattern ) : array
return array
    protected function getStagedFiles($pattern)
    {
        $filter = empty($pattern) ? '' : " | grep {$pattern}";
        $command = sprintf('LC_ALL=en_US.UTF-8 git diff-index --name-only --diff-filter=ACMR %s %s', escapeshellarg($this->getAgainst()), $filter);
        exec($command, $files, $return);
        if (2 === $return) {
            throw new \RuntimeException('Fetching staged files returns an error');
        }
        // No files found
        if (1 === $return) {
            return [];
        }
        // Filter out empty and NULL values
        $files = array_filter($files);
        array_walk($files, [$this, 'prependRoot'], $this->root);
        return $files;
    }