def commits(request): reposPath = request.GET['path'].replace("//", "/") if not checkRepoAuthorization(request,reposPath): return redirect(forbidden) repo = GitRepo(getGitPath() + sep + reposPath) until = None since = None try: branch = request.GET['branch'] if branch == '': branch = repo.head.commit.hexsha except KeyError: branch = repo.head.commit.hexsha try: filePath = request.GET['filePath'] except KeyError: filePath = None page = 1 num = 10 numPerPages = 15 if request.method == 'POST': filterForm = FilterForm(request.POST) if filterForm.is_valid(): num = filterForm.cleaned_data['number'] page = filterForm.cleaned_data['page'] if filterForm.cleaned_data['since'] is not None: since = int(time.mktime(filterForm.cleaned_data['since'].timetuple())) if filterForm.cleaned_data['until'] is not None: until = int(time.mktime(filterForm.cleaned_data['until'].timetuple())) commits = repo.getCommits(num=num, since=since, until=until, branch=branch, path=filePath) else: commits = repo.getCommits(num, branch=branch, path=filePath) else: filterForm = FilterForm() commits = repo.getCommits(num, branch=branch, path=filePath) #The page number is +1 page -= 1 if len(commits) > numPerPages: numPages = len(commits) / numPerPages if len(commits) % numPerPages > 0: numPages += 1 commits = commits[numPerPages * page:][:numPerPages] else: numPages = 1 if branch: branchForm = BranchForm(repo, request.GET) else: branchForm = BranchForm(repo) repoName = reposPath.split('/')[-1] if reposPath.rfind('/') > 0: moduleName = reposPath[:reposPath.rfind('/')] else: moduleName = '' if repo.bare: repoDesc = repo.getDescription() else: repoDesc = None return render_to_response("commits.html", RequestContext(request, { 'branchForm': branchForm, 'filterForm': filterForm, 'repoPath': reposPath, 'moduleName': moduleName, 'repoName': repoName, 'repoDesc': repoDesc, 'branch': branch, 'since': since, 'until': until, 'commits': commits, 'num': num, 'numPages': range(numPages + 1)[1:], 'page': page + 1, 'filePath': filePath, 'gitPath': getGitPath(), 'gitBasicUrl': settings.GIT_BASIC_URL }))