mirror of
https://github.com/correl/codereview.git
synced 2024-11-23 19:19:50 +00:00
Added paths to log view
This commit is contained in:
parent
e7285b2324
commit
981150f901
3 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'^(?P<repository>.*?)/log/$', 'codereview.browser.views.log'),
|
(r'^(?P<repository>.*?)/log/(?P<path>(.*?/)+)?$', 'codereview.browser.views.log'),
|
||||||
(r'^(?P<repository>.*?)/view/(?P<ref>.*?)/$', 'codereview.browser.views.view'),
|
(r'^(?P<repository>.*?)/view/(?P<ref>.*?)/$', 'codereview.browser.views.view'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Git(VCS):
|
||||||
def log(self, commit=None, path=None, max=50, offset=0):
|
def log(self, commit=None, path=None, max=50, offset=0):
|
||||||
commit = commit if commit else self._ref
|
commit = commit if commit else self._ref
|
||||||
result = []
|
result = []
|
||||||
for c in self._repo.iter_commits(commit, path, max_count=max,
|
for c in self._repo.iter_commits(rev=commit, paths=path, max_count=max,
|
||||||
skip=offset):
|
skip=offset):
|
||||||
result.append(self.commit(c))
|
result.append(self.commit(c))
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import os
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
from codereview.dashboard.models import Repository
|
from codereview.dashboard.models import Repository
|
||||||
from codereview.browser import vcs
|
from codereview.browser import vcs
|
||||||
|
|
||||||
def log(request,repository):
|
def log(request,repository, path=None):
|
||||||
try:
|
try:
|
||||||
repository = Repository.objects.get(name=repository)
|
repository = Repository.objects.get(name=repository)
|
||||||
except:
|
except:
|
||||||
|
@ -12,7 +13,10 @@ def log(request,repository):
|
||||||
ref = request.GET['c'] if 'c' in request.GET else repo.ref()
|
ref = request.GET['c'] if 'c' in request.GET else repo.ref()
|
||||||
offset = int(request.GET['o']) if 'o' in request.GET else 0
|
offset = int(request.GET['o']) if 'o' in request.GET else 0
|
||||||
limit = 20
|
limit = 20
|
||||||
log = repo.log(ref, max=limit, offset=offset)
|
|
||||||
|
path = os.path.dirname(path) if path else ''
|
||||||
|
log = repo.log(ref, path=path, max=limit, offset=offset)
|
||||||
|
navigation = dict(zip(('dirs', 'files'), repo.browse()))
|
||||||
|
|
||||||
newer = offset - limit if offset > limit else 0
|
newer = offset - limit if offset > limit else 0
|
||||||
# Inspect the last commit. If it has no parents, we can't go any further
|
# Inspect the last commit. If it has no parents, we can't go any further
|
||||||
|
@ -23,8 +27,10 @@ def log(request,repository):
|
||||||
return render_to_response('browser/log.html',
|
return render_to_response('browser/log.html',
|
||||||
{
|
{
|
||||||
'repository': repository,
|
'repository': repository,
|
||||||
|
'path': path,
|
||||||
'repo': repo,
|
'repo': repo,
|
||||||
'log': log,
|
'log': log,
|
||||||
|
'navigation': navigation,
|
||||||
'ref': ref,
|
'ref': ref,
|
||||||
'offset': offset,
|
'offset': offset,
|
||||||
'newer': newer,
|
'newer': newer,
|
||||||
|
|
Loading…
Reference in a new issue