class File
{
/**
- * Full path to the file
+ * Path to the file, relative to repository work directory
*
* @var string
*/
*/
public $repo;
+ /**
+ * Commit revision this file is at
+ */
+ public $hash;
+
public function __construct($path, Repository $repo = null)
{
$this->path = $path;
*/
public function getFilename()
{
- return basename($this->path);
+ return $this->path;
}
/**
*
* @return string
*/
- public function getPath()
+ public function getFullPath()
{
- return $this->path;
+ return $this->repo->workDir . '/' . $this->path;
}
/**
public function getContent()
{
- return file_get_contents($this->path);
+ if ($this->repo->hash) {
+ return $this->repo->getVc()->getCommand('show')
+ ->addArgument($this->repo->hash . ':' . $this->path)
+ ->execute();
+ }
+
+ return file_get_contents($this->getFullPath());
}
public function getRenderedContent(Tool_Result $res = null)