From c897090812e3bee5024b84bdfa5d5d73bc5dacd3 Mon Sep 17 00:00:00 2001 From: Ilia Kondrashov Date: Fri, 26 Apr 2013 22:01:17 +0400 Subject: [PATCH] add GET search alias, put last query qery in input field --- src/GitList/Controller/CommitController.php | 9 +++++++++ src/GitList/Git/Repository.php | 1 + views/layout_page.twig | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/GitList/Controller/CommitController.php b/src/GitList/Controller/CommitController.php index e0171608..6e24c202 100644 --- a/src/GitList/Controller/CommitController.php +++ b/src/GitList/Controller/CommitController.php @@ -12,6 +12,15 @@ public function connect(Application $app) { $route = $app['controllers_factory']; + $route->get('{repo}/commits/search', function (Request $request, $repo) use ($app) { + $subRequest = Request::create( + '/' . $repo . '/commits/master/search', + 'POST', + array('query' => $request->get('query')) + ); + return $app->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST); + })->assert('repo', $app['util.routing']->getRepositoryRegex()); + $route->get('{repo}/commits/{commitishPath}', function ($repo, $commitishPath) use ($app) { $repository = $app['git']->getRepository($app['git.repos'], $repo); diff --git a/src/GitList/Git/Repository.php b/src/GitList/Git/Repository.php index a4969a2a..cc71e4aa 100644 --- a/src/GitList/Git/Repository.php +++ b/src/GitList/Git/Repository.php @@ -241,6 +241,7 @@ public function getPaginatedCommits($file = null, $page = 0) public function searchCommitLog($query) { $query = escapeshellarg($query); + $query = strtr($query, array('[' => '\\[', ']' => '\\]')); $command = "log --grep={$query} --pretty=format:\"%H" . "%h%T%P" diff --git a/views/layout_page.twig b/views/layout_page.twig index 02919b97..45665af0 100644 --- a/views/layout_page.twig +++ b/views/layout_page.twig @@ -8,11 +8,11 @@
{% if page in ['commits', 'searchcommits'] %} {% else %} {% endif %}