diff --git a/src/VersionControl/GitCommandBundle/Entity/FileInfo.php b/src/VersionControl/GitCommandBundle/Entity/FileInfo.php index b15208b..921131c 100644 --- a/src/VersionControl/GitCommandBundle/Entity/FileInfo.php +++ b/src/VersionControl/GitCommandBundle/Entity/FileInfo.php @@ -33,24 +33,47 @@ class FileInfo extends \SplFileInfo{ */ protected $gitLog; - + /** + * Gets the git log for the file + * @return \VersionControl\GitCommandBundle\Entity\GitLog + */ public function getGitLog() { return $this->gitLog; } + /** + * Sets the git log for the file + * @param \VersionControl\GitCommandBundle\Entity\GitLog $gitLog + * @return \VersionControl\GitCommandBundle\Entity\FileInfo + */ public function setGitLog(GitLog $gitLog) { $this->gitLog = $gitLog; return $this; } + /** + * Gets absolute path to file. Wrapper for SplFileInfo::getRealPath + * + * @link http://php.net/manual/en/splfileinfo.getrealpath.php + * @return string + */ public function getFullPath() { return $this->getRealPath(); } - + + /** + * Gets the file path relative to the .git folder + * @return string + */ public function getGitPath() { return $this->gitPath; } + /** + * Sets the file path relative to the .git folder + * @param string $gitPath + * @return \VersionControl\GitCommandBundle\Entity\FileInfo + */ public function setGitPath($gitPath) { $this->gitPath = $gitPath; return $this; diff --git a/src/VersionControl/GitCommandBundle/Entity/RemoteFileInfo.php b/src/VersionControl/GitCommandBundle/Entity/RemoteFileInfo.php index 39b6b8b..85a2a8f 100644 --- a/src/VersionControl/GitCommandBundle/Entity/RemoteFileInfo.php +++ b/src/VersionControl/GitCommandBundle/Entity/RemoteFileInfo.php @@ -20,16 +20,45 @@ class RemoteFileInfo{ /** - * File full path to file + * Absolute path to file * @var string */ protected $fullPath; + /** + * File Extension + * @var string + */ protected $extension; + + /** + * File name without any path information + * @var string + */ protected $filename; + + /** + * Path without the filename + * @var string + */ protected $path; + + /** + * File permissions + * @var string + */ protected $perms; + + /** + * Filesize in bytes + * @var integer + */ protected $size; + + /** + * + * @var type + */ protected $uid; protected $gid; protected $mode; @@ -40,9 +69,7 @@ class RemoteFileInfo{ protected $gitPath; - - - + /** * Git log Entity * @var GitLog diff --git a/src/VersionControl/GitCommandBundle/GitCommands/Command/GitFilesCommand.php b/src/VersionControl/GitCommandBundle/GitCommands/Command/GitFilesCommand.php index b7282ca..f86b626 100644 --- a/src/VersionControl/GitCommandBundle/GitCommands/Command/GitFilesCommand.php +++ b/src/VersionControl/GitCommandBundle/GitCommands/Command/GitFilesCommand.php @@ -78,8 +78,9 @@ protected function getFileInfo($path){ $fileData = $sftp->stat($basePath.$path); + $fileData['filename'] = basename($path); $fileData['fullPath'] = $basePath.$path; - $fileData['gitPath'] = $basePath.$path; + $fileData['gitPath'] = $path; $fileInfo = new RemoteFileInfo($fileData); }else{ @@ -168,7 +169,7 @@ public function getFilesInDirectory($dir){ foreach($sftp->rawlist($basePath.$relativePath) as $filename => $fileData) { if($filename !== '.' && $filename !== '..' && $filename !== '.git'){ - $fileData['fullPath'] = rtrim($relativePath,'/').'/'.$filename; + $fileData['fullPath'] = $basePath.rtrim($relativePath,'/').'/'.$filename; $fileData['gitPath'] = $relativePath.$filename; $remoteFileInfo = new RemoteFileInfo($fileData); @@ -386,7 +387,7 @@ public function filePathIsIgnored($filePath){ public function getGitIgnoreFile(){ $ignoreFiles = array(); - + $basePath = trim($this->addEndingSlash($this->command->getGitEnvironment()->getPath())); $fileData['fullPath'] = '.gitignore'; $fileData['gitPath'] = '.gitignore'; diff --git a/src/VersionControl/GitControlBundle/Controller/ProjectFilesController.php b/src/VersionControl/GitControlBundle/Controller/ProjectFilesController.php index 1cabcae..f050ea6 100644 --- a/src/VersionControl/GitControlBundle/Controller/ProjectFilesController.php +++ b/src/VersionControl/GitControlBundle/Controller/ProjectFilesController.php @@ -80,20 +80,24 @@ public function fileListAction($id,$currentDir = ''){ public function viewFileAction($id,$currentFile = ''){ $filePath = ''; $dir = ''; + $currentDir = ''; if($currentFile){ $filePath = trim(urldecode($currentFile)); $file = $this->gitFilesCommands->getFile($filePath, $this->branchName); - $fileContents = $this->gitFilesCommands->readFile($file); $pathParts = pathinfo($filePath); $dir = $pathParts['dirname']; + + $pathParts = pathinfo($filePath); + $currentDir = ($pathParts['dirname'] !== '.')?$pathParts['dirname']:''; } return array_merge($this->viewVariables, array( - 'currentDir' => $filePath, + 'currentDir' => $currentDir, + 'filePath' => $filePath, 'fileContents' => $fileContents, 'file' => $file )); diff --git a/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/fileList.html.twig b/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/fileList.html.twig index 840fab2..1d27900 100644 --- a/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/fileList.html.twig +++ b/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/fileList.html.twig @@ -69,8 +69,7 @@ {% if(currentDir) %}
-
- +
.. diff --git a/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/viewFile.html.twig b/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/viewFile.html.twig index 2d550dc..b2a9f3c 100644 --- a/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/viewFile.html.twig +++ b/src/VersionControl/GitControlBundle/Resources/views/ProjectFiles/viewFile.html.twig @@ -40,10 +40,25 @@

Shows file contents of the current working directory.

+
+
+
+ {% if(currentDir) %} + + Back to /{{currentDir}} + + {% else %} + + Back to / + + {% endif %} +
+
+
- Path:/{{currentDir}} + Path:/{{filePath}}