/** * Commit the file (needs write access to repository) * * @param string comment */ public function commit($comment) { $f = new TempFile(); $f->open(FILE_MODE_WRITE); $f->writeLine($comment); $f->close(); $return = $this->_execute(sprintf('commit -F %s %s', $f->getURI(), $this->filename)); $f->unlink(); return $return; }
/** * Produce diff between the contents * * @param string left * @param string right */ protected function diff($left, $right) { with($templ = new TempFile(), $tempr = new TempFile(), $templ->open(FILE_MODE_WRITE), $tempr->open(FILE_MODE_WRITE)); $templ->write($left); $tempr->write($right); $templ->close(); $tempr->close(); // TODO: Implement "diff" in userland try { $p = new Process(sprintf('diff -u %s %s', $templ->getURI(), $tempr->getURI())); $p->in->close(); while (!$p->out->eof()) { $this->out->writeLine($p->out->readLine()); } $p->close(); } catch (IOException $e) { $this->err->writeLine('!=> Invocation of `diff` program failed.'); $templ->unlink(); $tempr->unlink(); return; } $templ->unlink(); $tempr->unlink(); }