/**
  * Show Git commit diff.
  *
  * @Route("/{currentFile}",defaults={"$currentFile" = ""}, name="project_viewfile")
  * @Method("GET")
  * @Template()
  * @ProjectAccess(grantType="VIEW")
  */
 public function viewFileAction($id, $currentFile = '')
 {
     $filePath = '';
     $dir = '';
     $currentDir = '';
     if ($currentFile) {
         $filePath = trim(urldecode($currentFile));
         try {
             $file = $this->gitFilesCommands->getFile($filePath, $this->branchName);
             $fileContents = $this->gitFilesCommands->readFile($file);
         } catch (\Exception $e) {
             $this->get('session')->getFlashBag()->add('error', $e->getMessage());
         }
         $pathParts = pathinfo($filePath);
         $dir = $pathParts['dirname'];
         $pathParts = pathinfo($filePath);
         $currentDir = $pathParts['dirname'] !== '.' ? $pathParts['dirname'] : '';
     }
     return array_merge($this->viewVariables, array('currentDir' => $currentDir, 'filePath' => $filePath, 'fileContents' => $fileContents, 'file' => $file));
 }