Example #1
0
 def get_context_data(self, **kwargs):
     context = super(DiffDetailView, self).get_context_data(**kwargs)
     
     file_path = self.request.GET.get('path')
     if not file_path:
         raise Http404("No file specified.")
     
     commit_a, rev_type_a, rev_name_a = _get_rev(self.request.GET.get('branch_a'), self.request.GET.get('commit_a'))
     commit_b, rev_type_b, rev_name_b = _get_rev(self.request.GET.get('branch_b'), self.request.GET.get('commit_b'))
     
     diff_index = commit_a.diff(commit_b, create_patch=True)
     
     diff_info = repository.get_diff_by_path(diff_index, file_path)
     if not diff_info:
         raise Http404("Diff doesn't exist.")
     
     context['file_path'] = file_path
     context['diff'] = diff_info
     context['file_contents_a'] = repository.get_blob_contents(diff_info.a_blob) if not diff_info.new_file else None
     context['file_contents_b'] = repository.get_blob_contents(diff_info.b_blob) if not diff_info.deleted_file else None
     context['rev_type_a'] = rev_type_a
     context['rev_type_b'] = rev_type_b
     context['rev_name_a'] = rev_name_a
     context['rev_name_b'] = rev_name_b
     context['all_branches'] = repository.branches()
     
     return context
Example #2
0
    def get_context_data(self, **kwargs):
        context = super(BrowseSourceView, self).get_context_data(**kwargs)
        
        commit, rev_type, rev_name = _get_rev(self.request.GET.get('branch'), self.request.GET.get('commit'))

        context['file_tree_data'] = repository.tree_as_json(commit.tree, rev_type, rev_name)
        context['rev_name'] = rev_name
        context['rev_type'] = rev_type
        context['all_branches'] = repository.branches()
        
        return context
Example #3
0
 def get_context_data(self, **kwargs):
     context = super(CommitListView, self).get_context_data(**kwargs)
     
     rev = _get_rev(self.request.GET.get('branch'), self.request.GET.get('commit'), default_branch_name=None)
     if rev is None:
         rev_name = None
     else:
         _, _, rev_name = rev
     
     context['rev_name'] = rev_name if rev_name else "All"
     context['commits'] = repository.commits(rev_name)
     context['all_branches'] = repository.branches()
     
     return context
Example #4
0
 def get_context_data(self, **kwargs):
     context = super(CommitDetailView, self).get_context_data(**kwargs)
     
     commit_sha = kwargs.get('commit')
     if not commit_sha:
         raise Http404("No commit specified.")
     
     commit = repository.commit(commit_sha)
     
     if not commit:
         raise Http404("A commit with sha "+commit_sha+" doesn't exists.")
     
     context['commit'] = commit
     context['all_branches'] = repository.branches()
     
     return context
Example #5
0
 def get_context_data(self, **kwargs):
     context = super(DiffListView, self).get_context_data(**kwargs)
     
     commit_a, rev_type_a, rev_name_a = _get_rev(self.request.GET.get('branch_a'), self.request.GET.get('commit_a'))
     commit_b, rev_type_b, rev_name_b = _get_rev(self.request.GET.get('branch_b'), self.request.GET.get('commit_b'))
     
     diff_index = commit_a.diff(commit_b)
     
     context['diff_index'] = diff_index
     context['rev_type_a'] = rev_type_a
     context['rev_type_b'] = rev_type_b
     context['rev_name_a'] = rev_name_a
     context['rev_name_b'] = rev_name_b
     context['all_branches'] = repository.branches()
     
     return context
Example #6
0
 def get_context_data(self, **kwargs):
     context = super(FileContentsView, self).get_context_data(**kwargs)
     
     file_path = self.request.GET.get('path')
     if not file_path:
         raise Http404("No file specified.")
     
     commit, rev_type, rev_name = _get_rev(self.request.GET.get('branch'), self.request.GET.get('commit'))
     
     try:
         context['file_contents'] = repository.get_blob_contents(commit.tree[file_path])
     except:
         context['file_contents'] = "Non-text file"
     context['file_path'] = file_path
     context['rev_name'] = rev_name
     context['rev_type'] = rev_type
     context['all_branches'] = repository.branches()
     
     return context
Example #7
0
 def get_context_data(self, **kwargs):
     context = super(DiffSelectView, self).get_context_data(**kwargs)
     context['all_branches'] = repository.branches()
     return context