Return the filename relative to its sourceroot.
public getSourcerootPath ( ) : string | ||
return | string | Pathname relative to the sourceroot. |
/** * Return the name of this file relative to its sourceroot. * * @return string Pathname relative to the sourceroot. */ public function getSourcerootPath() { return substr(parent::getSourcerootPath(), 0, -2); }
/** * Obtain the differences between two revisions of a file. * * @param Horde_Vcs_File_Git $file The desired file. * @param string $rev1 Original revision number to compare * from. * @param string $rev2 New revision number to compare against. * @param array $opts The following optional options: * - 'num': (integer) DEFAULT: 3 * - 'type': (string) DEFAULT: 'unified' * - 'ws': (boolean) DEFAULT: true * * @return string The diff text. */ protected function _diff(Horde_Vcs_File_Base $file, $rev1, $rev2, $opts) { $diff = array(); $flags = ''; if (!$opts['ws']) { $flags .= ' -b -w '; } if (!$rev1) { $command = $this->getCommand() . ' show --oneline ' . escapeshellarg($rev2) . ' -- ' . escapeshellarg($file->getSourcerootPath()) . ' 2>&1'; } else { switch ($opts['type']) { case 'unified': $flags .= '--unified=' . escapeshellarg((int) $opts['num']); break; } // @TODO: add options for $hr options - however these may not // be compatible with some diffs. $command = $this->getCommand() . ' diff -M -C ' . $flags . ' --no-color ' . escapeshellarg($rev1 . '..' . $rev2) . ' -- ' . escapeshellarg($file->getSourcerootPath()) . ' 2>&1'; } exec($command, $diff); return $diff; }