public function __construct(Context $context, \GitElephant\Status\StatusFile $statusFile, $subpath = null) { $this->obj = $statusFile; $this->filename = $statusFile->getName(); if ($subpath) { $this->filename = $subpath . $this->filename; } $this->status = $statusFile->getWorkingTreeStatus(); $fullfilename = $context->getPath() . '/' . $this->filename; if (file_exists($fullfilename)) { $this->mtime = \DateTime::createFromFormat('U', filemtime($fullfilename)); $this->mtime->setTimezone(new \DateTimeZone(\date_default_timezone_get())); } }
/** * create objects from command output * https://www.kernel.org/pub/software/scm/git/docs/git-status.html in the output section * * * @param array $lines */ private function parseOutputLines($lines) { foreach ($lines as $line) { preg_match('/([MADRCU\\? ])?([MADRCU\\? ])?\\ "?(\\S+)"? ?( -> )?(\\S+)?/', $line, $matches); $x = isset($matches[1]) ? $matches[1] : null; $y = isset($matches[2]) ? $matches[2] : null; $file = isset($matches[3]) ? $matches[3] : null; $renamedFile = isset($matches[4]) ? $matches[4] : null; $this->files[] = StatusFile::create($x, $y, $file, $renamedFile); } }