From cfb299cf4f7cdd29996da5ffedfabb299cb316d6 Mon Sep 17 00:00:00 2001 From: Marcel Deglau Date: Thu, 1 Sep 2016 22:47:40 +0200 Subject: [PATCH 1/2] Move TreeGraphController.php into Controller Move TreeGraphController.php from src/GitList/Controller into Controller to fix fresh install issues. --- src/Controller/TreeGraphController.php | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Controller/TreeGraphController.php diff --git a/src/Controller/TreeGraphController.php b/src/Controller/TreeGraphController.php new file mode 100644 index 0000000..ecf0c06 --- /dev/null +++ b/src/Controller/TreeGraphController.php @@ -0,0 +1,73 @@ +get( + '{repo}/treegraph/{commitishPath}', + function ($repo, $commitishPath) use ($app) { + /** @var \GitList\Git\Repository $repository */ + $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo); + + $command = 'log --graph --date-order --all -C -M -n 100 --date=iso ' . + '--pretty=format:"B[%d] C[%H] D[%ad] A[%an] E[%ae] H[%h] S[%s]"'; + $rawRows = $repository->getClient()->run($repository, $command); + $rawRows = explode("\n", $rawRows); + $graphItems = array(); + + foreach ($rawRows as $row) { + if (preg_match("/^(.+?)(\s(B\[(.*?)\])? C\[(.+?)\] D\[(.+?)\] A\[(.+?)\] E\[(.+?)\] H\[(.+?)\] S\[(.+?)\])?$/", $row, $output)) { + if (!isset($output[4])) { + $graphItems[] = array( + "relation"=>$output[1] + ); + continue; + } + $graphItems[] = array( + "relation"=>$output[1], + "branch"=>$output[4], + "rev"=>$output[5], + "date"=>$output[6], + "author"=>$output[7], + "author_email"=>$output[8], + "short_rev"=>$output[9], + "subject"=>preg_replace('/(^|\s)(#[[:xdigit:]]+)(\s|$)/', '$1$2$3', $output[10]) + ); + } + } + + if ($commitishPath === null) { + $commitishPath = $repository->getHead(); + } + + list($branch, $file) = $app['util.routing']->parseCommitishPathParam($commitishPath, $repo); + list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file); + + return $app['twig']->render( + 'treegraph.twig', + array( + 'repo' => $repo, + 'branch' => $branch, + 'commitishPath' => $commitishPath, + 'graphItems' => $graphItems, + ) + ); + } + )->assert('repo', $app['util.routing']->getRepositoryRegex()) + ->assert('commitishPath', $app['util.routing']->getCommitishPathRegex()) + ->value('commitishPath', null) + ->convert('commitishPath', 'escaper.argument:escape') + ->bind('treegraph'); + + return $route; + } +} From 07983ab69f8685bd37d3e8a23ba174c88bba4556 Mon Sep 17 00:00:00 2001 From: Marcel Deglau Date: Thu, 1 Sep 2016 22:48:15 +0200 Subject: [PATCH 2/2] Move TreeGraphController.php into Controller (Delete this one) --- .../Controller/TreeGraphController.php | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/GitList/Controller/TreeGraphController.php diff --git a/src/GitList/Controller/TreeGraphController.php b/src/GitList/Controller/TreeGraphController.php deleted file mode 100644 index ecf0c06..0000000 --- a/src/GitList/Controller/TreeGraphController.php +++ /dev/null @@ -1,73 +0,0 @@ -get( - '{repo}/treegraph/{commitishPath}', - function ($repo, $commitishPath) use ($app) { - /** @var \GitList\Git\Repository $repository */ - $repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo); - - $command = 'log --graph --date-order --all -C -M -n 100 --date=iso ' . - '--pretty=format:"B[%d] C[%H] D[%ad] A[%an] E[%ae] H[%h] S[%s]"'; - $rawRows = $repository->getClient()->run($repository, $command); - $rawRows = explode("\n", $rawRows); - $graphItems = array(); - - foreach ($rawRows as $row) { - if (preg_match("/^(.+?)(\s(B\[(.*?)\])? C\[(.+?)\] D\[(.+?)\] A\[(.+?)\] E\[(.+?)\] H\[(.+?)\] S\[(.+?)\])?$/", $row, $output)) { - if (!isset($output[4])) { - $graphItems[] = array( - "relation"=>$output[1] - ); - continue; - } - $graphItems[] = array( - "relation"=>$output[1], - "branch"=>$output[4], - "rev"=>$output[5], - "date"=>$output[6], - "author"=>$output[7], - "author_email"=>$output[8], - "short_rev"=>$output[9], - "subject"=>preg_replace('/(^|\s)(#[[:xdigit:]]+)(\s|$)/', '$1$2$3', $output[10]) - ); - } - } - - if ($commitishPath === null) { - $commitishPath = $repository->getHead(); - } - - list($branch, $file) = $app['util.routing']->parseCommitishPathParam($commitishPath, $repo); - list($branch, $file) = $app['util.repository']->extractRef($repository, $branch, $file); - - return $app['twig']->render( - 'treegraph.twig', - array( - 'repo' => $repo, - 'branch' => $branch, - 'commitishPath' => $commitishPath, - 'graphItems' => $graphItems, - ) - ); - } - )->assert('repo', $app['util.routing']->getRepositoryRegex()) - ->assert('commitishPath', $app['util.routing']->getCommitishPathRegex()) - ->value('commitishPath', null) - ->convert('commitishPath', 'escaper.argument:escape') - ->bind('treegraph'); - - return $route; - } -}