Skip to content

Commit

Permalink
Merge pull request #316 from caseycs/search_improve
Browse files Browse the repository at this point in the history
add GET search alias, put last search query in input field
  • Loading branch information
klaussilveira committed Mar 29, 2014
2 parents 61c1fbd + 8e8b6ec commit 5196a25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/GitList/Controller/CommitController.php
Expand Up @@ -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']->getRepositoryFromName($app['git.repos'], $repo);

Expand Down
1 change: 1 addition & 0 deletions src/GitList/Git/Repository.php
Expand Up @@ -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:\"<item><hash>%H</hash>"
. "<short_hash>%h</short_hash><tree>%T</tree><parents>%P</parents>"
Expand Down
4 changes: 2 additions & 2 deletions views/layout_page.twig
Expand Up @@ -8,11 +8,11 @@
<div class="span12">
{% if page in ['commits', 'searchcommits'] %}
<form class="form-search pull-right" action="{{ app.request.basepath }}/{{repo}}/commits/{{branch}}/search" method="POST">
<input type="text" name="query" class="input-medium search-query" placeholder="Search commits...">
<input type="text" name="query" class="input-medium search-query" placeholder="Search commits..." value="{{ query }}">
</form>
{% else %}
<form class="form-search pull-right" action="{{ app.request.basepath }}/{{repo}}/tree/{{branch}}/search" method="POST">
<input type="text" name="query" class="input-medium search-query" placeholder="Search tree...">
<input type="text" name="query" class="input-medium search-query" placeholder="Search tree..." value="{{ query }}">
</form>
{% endif %}

Expand Down

0 comments on commit 5196a25

Please sign in to comment.