mirror of
https://github.com/klaussilveira/gitlist.git
synced 2025-11-18 11:40:57 +01:00
add GET search alias, put last query qery in input field
This commit is contained in:
@@ -12,6 +12,15 @@ class CommitController implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$route = $app['controllers_factory'];
|
$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) {
|
$route->get('{repo}/commits/{commitishPath}', function ($repo, $commitishPath) use ($app) {
|
||||||
$repository = $app['git']->getRepository($app['git.repos'], $repo);
|
$repository = $app['git']->getRepository($app['git.repos'], $repo);
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ class Repository extends BaseRepository
|
|||||||
public function searchCommitLog($query)
|
public function searchCommitLog($query)
|
||||||
{
|
{
|
||||||
$query = escapeshellarg($query);
|
$query = escapeshellarg($query);
|
||||||
|
$query = strtr($query, array('[' => '\\[', ']' => '\\]'));
|
||||||
$command =
|
$command =
|
||||||
"log --grep={$query} --pretty=format:\"<item><hash>%H</hash>"
|
"log --grep={$query} --pretty=format:\"<item><hash>%H</hash>"
|
||||||
. "<short_hash>%h</short_hash><tree>%T</tree><parent>%P</parent>"
|
. "<short_hash>%h</short_hash><tree>%T</tree><parent>%P</parent>"
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
<div class="span12">
|
<div class="span12">
|
||||||
{% if page in ['commits', 'searchcommits'] %}
|
{% if page in ['commits', 'searchcommits'] %}
|
||||||
<form class="form-search pull-right" action="{{ app.request.basepath }}/{{repo}}/commits/{{branch}}/search" method="POST">
|
<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>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<form class="form-search pull-right" action="{{ app.request.basepath }}/{{repo}}/tree/{{branch}}/search" method="POST">
|
<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>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user