fix(submodules): fixed an error if reaching out submodule path.
- small UI fixes - cleanups of submodule code
This commit is contained in:
parent
86f20fdf18
commit
2b92d7fa48
5 changed files with 105 additions and 84 deletions
|
|
@ -647,32 +647,6 @@ class RepoFilesView(RepoAppView):
|
|||
c.f_path = f_path
|
||||
at_rev = self.request.GET.get('at')
|
||||
|
||||
# prev link
|
||||
try:
|
||||
prev_commit = c.commit.prev(c.branch)
|
||||
c.prev_commit = prev_commit
|
||||
c.url_prev = h.route_path(
|
||||
'repo_files', repo_name=self.db_repo_name,
|
||||
commit_id=prev_commit.raw_id, f_path=f_path)
|
||||
if c.branch:
|
||||
c.url_prev += '?branch=%s' % c.branch
|
||||
except (CommitDoesNotExistError, VCSError):
|
||||
c.url_prev = '#'
|
||||
c.prev_commit = EmptyCommit()
|
||||
|
||||
# next link
|
||||
try:
|
||||
next_commit = c.commit.next(c.branch)
|
||||
c.next_commit = next_commit
|
||||
c.url_next = h.route_path(
|
||||
'repo_files', repo_name=self.db_repo_name,
|
||||
commit_id=next_commit.raw_id, f_path=f_path)
|
||||
if c.branch:
|
||||
c.url_next += '?branch=%s' % c.branch
|
||||
except (CommitDoesNotExistError, VCSError):
|
||||
c.url_next = '#'
|
||||
c.next_commit = EmptyCommit()
|
||||
|
||||
# files or dirs
|
||||
try:
|
||||
c.file = c.commit.get_node(f_path, pre_load=['is_binary', 'size', 'data'])
|
||||
|
|
@ -680,8 +654,35 @@ class RepoFilesView(RepoAppView):
|
|||
c.file_author = True
|
||||
c.file_tree = ''
|
||||
|
||||
# prev link
|
||||
try:
|
||||
prev_commit = c.commit.prev(c.branch)
|
||||
c.prev_commit = prev_commit
|
||||
c.url_prev = h.route_path(
|
||||
'repo_files', repo_name=self.db_repo_name,
|
||||
commit_id=prev_commit.raw_id, f_path=f_path)
|
||||
if c.branch:
|
||||
c.url_prev += '?branch=%s' % c.branch
|
||||
except (CommitDoesNotExistError, VCSError):
|
||||
c.url_prev = '#'
|
||||
c.prev_commit = EmptyCommit()
|
||||
|
||||
# next link
|
||||
try:
|
||||
next_commit = c.commit.next(c.branch)
|
||||
c.next_commit = next_commit
|
||||
c.url_next = h.route_path(
|
||||
'repo_files', repo_name=self.db_repo_name,
|
||||
commit_id=next_commit.raw_id, f_path=f_path)
|
||||
if c.branch:
|
||||
c.url_next += '?branch=%s' % c.branch
|
||||
except (CommitDoesNotExistError, VCSError):
|
||||
c.url_next = '#'
|
||||
c.next_commit = EmptyCommit()
|
||||
|
||||
# load file content
|
||||
if c.file.is_file():
|
||||
|
||||
c.lf_node = {}
|
||||
|
||||
has_lf_enabled = self._is_lf_enabled(self.db_repo)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ from rhodecode.lib.utils2 import (
|
|||
safe_str, remove_prefix, obfuscate_url_pw,
|
||||
get_current_rhodecode_user, safe_int, action_logger_generic)
|
||||
from rhodecode.lib.vcs.backends import get_backend
|
||||
from rhodecode.lib.vcs.nodes import NodeKind
|
||||
from rhodecode.model import BaseModel
|
||||
from rhodecode.model.db import (
|
||||
_hash_key, func, case, joinedload, or_, in_filter_generator,
|
||||
|
|
@ -1128,6 +1129,10 @@ class ReadmeFinder:
|
|||
"""
|
||||
Find a readme in the given `commit`.
|
||||
"""
|
||||
# firstly, check the PATH type if it is actually a DIR
|
||||
if commit.get_node(path).kind != NodeKind.DIR:
|
||||
return None
|
||||
|
||||
nodes = commit.get_nodes(path)
|
||||
matches = self._match_readmes(nodes)
|
||||
matches = self._sort_according_to_priority(matches)
|
||||
|
|
|
|||
|
|
@ -264,7 +264,10 @@ They are permanent until deleted, or converted to regular comments.<br/>
|
|||
|
||||
</script>
|
||||
|
||||
|
||||
<script id="ejs_submoduleHovercard" type="text/template" class="ejsTemplate">
|
||||
<strong>Submodule Node</strong><br/>
|
||||
<pre><%= submodule_url %></pre>
|
||||
</script>
|
||||
|
||||
##// END OF EJS Templates
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
<%namespace name="base" file="/base/base.mako"/>
|
||||
|
||||
<%doc>
|
||||
Please note the content of this file is cached, so changes here might not be reflected when editing.
|
||||
add ?no-cache=true into the file url to disable caches.
|
||||
|
||||
e.g
|
||||
http://docker-dev:10020/ipython/files/master/IPython/frontend/html/notebook/static?no-cache=1
|
||||
|
||||
</%doc>
|
||||
<%
|
||||
at_ref = request.GET.get('at')
|
||||
if at_ref:
|
||||
|
|
@ -29,65 +37,71 @@
|
|||
</tr>
|
||||
|
||||
<% has_files = False %>
|
||||
% for cnt,node in enumerate(c.file):
|
||||
<% has_files = True %>
|
||||
<tr class="parity${(cnt % 2)}">
|
||||
<td class="td-componentname">
|
||||
% if node.is_submodule():
|
||||
<span class="submodule-dir">
|
||||
% if node.url.startswith('http://') or node.url.startswith('https://'):
|
||||
<a href="${node.url}">
|
||||
<i class="icon-directory browser-dir"></i>${node.name}
|
||||
</a>
|
||||
% if not c.file.is_submodule():
|
||||
% for cnt, node in enumerate(c.file):
|
||||
<% has_files = True %>
|
||||
<tr class="parity${(cnt % 2)}">
|
||||
<td class="td-componentname">
|
||||
% if node.is_submodule():
|
||||
<span class="submodule-dir">
|
||||
% if node.url.startswith('http://') or node.url.startswith('https://'):
|
||||
<a href="${node.url}">
|
||||
<i class="icon-directory browser-dir"></i><span class="tooltip-hovercard" data-hovercard-alt="${node.url}" data-hovercard-url="javascript:renderTemplate('submoduleHovercard', {'submodule_url':'${node.url}'})">${node.name}</span>
|
||||
</a>
|
||||
% else:
|
||||
<i class="icon-directory browser-dir"></i><span class="tooltip-hovercard" data-hovercard-alt="${node.url}" data-hovercard-url="javascript:renderTemplate('submoduleHovercard', {'submodule_url':'${node.url}'})">${node.name}</span>
|
||||
% endif
|
||||
</span>
|
||||
% else:
|
||||
<i class="icon-directory browser-dir"></i>${node.name}
|
||||
<a href="${h.repo_files_by_ref_url(c.repo_name, c.rhodecode_db_repo.repo_type, f_path=h.safe_str(node.path), ref_name=default_landing_ref, commit_id=c.commit.raw_id, query=query)}">
|
||||
<i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name}
|
||||
</a>
|
||||
% endif
|
||||
</span>
|
||||
% else:
|
||||
<a href="${h.repo_files_by_ref_url(c.repo_name, c.rhodecode_db_repo.repo_type, f_path=h.safe_str(node.path), ref_name=default_landing_ref, commit_id=c.commit.raw_id, query=query)}">
|
||||
<i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name}
|
||||
</a>
|
||||
% endif
|
||||
</td>
|
||||
%if node.is_file():
|
||||
<td class="td-size" data-attr-name="size">
|
||||
% if c.full_load:
|
||||
<span data-size="${node.size}">${h.format_byte_size_binary(node.size)}</span>
|
||||
% else:
|
||||
${_('Loading ...')}
|
||||
% endif
|
||||
</td>
|
||||
<td class="td-time" data-attr-name="modified_at">
|
||||
% if c.full_load:
|
||||
<span data-date="${node.last_commit.date}">${h.age_component(node.last_commit.date)}</span>
|
||||
% endif
|
||||
</td>
|
||||
<td class="td-hash" data-attr-name="commit_id">
|
||||
% if c.full_load:
|
||||
<div class="tooltip-hovercard" data-hovercard-alt="${node.last_commit.message}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=c.repo_name, commit_id=node.last_commit.raw_id)}">
|
||||
<pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre>
|
||||
</div>
|
||||
% endif
|
||||
</td>
|
||||
<td class="td-user" data-attr-name="author">
|
||||
% if c.full_load:
|
||||
<span data-author="${node.last_commit.author}">${h.gravatar_with_user(request, node.last_commit.author, tooltip=True)|n}</span>
|
||||
% endif
|
||||
</td>
|
||||
%else:
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
%endif
|
||||
</tr>
|
||||
% endfor
|
||||
</td>
|
||||
%if node.is_file():
|
||||
<td class="td-size" data-attr-name="size">
|
||||
% if c.full_load:
|
||||
<span data-size="${node.size}">${h.format_byte_size_binary(node.size)}</span>
|
||||
% else:
|
||||
${_('Loading ...')}
|
||||
% endif
|
||||
</td>
|
||||
<td class="td-time" data-attr-name="modified_at">
|
||||
% if c.full_load:
|
||||
<span data-date="${node.last_commit.date}">${h.age_component(node.last_commit.date)}</span>
|
||||
% endif
|
||||
</td>
|
||||
<td class="td-hash" data-attr-name="commit_id">
|
||||
% if c.full_load:
|
||||
<div class="tooltip-hovercard" data-hovercard-alt="${node.last_commit.message}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=c.repo_name, commit_id=node.last_commit.raw_id)}">
|
||||
<pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre>
|
||||
</div>
|
||||
% endif
|
||||
</td>
|
||||
<td class="td-user" data-attr-name="author">
|
||||
% if c.full_load:
|
||||
<span data-author="${node.last_commit.author}">${h.gravatar_with_user(request, node.last_commit.author, tooltip=True)|n}</span>
|
||||
% endif
|
||||
</td>
|
||||
%else:
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
%endif
|
||||
</tr>
|
||||
% endfor
|
||||
% endif
|
||||
|
||||
% if not has_files:
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
##empty-dir mostly SVN
|
||||
|
||||
|
||||
## submodule if we somehow endup
|
||||
% if c.file.is_submodule():
|
||||
<span class="submodule-dir">Submodule ${h.escape(c.file.name)}</span>
|
||||
%endif
|
||||
</td>
|
||||
</tr>
|
||||
% endif
|
||||
|
|
|
|||
|
|
@ -15,17 +15,15 @@
|
|||
<div class="summary-detail-header">
|
||||
|
||||
</div><!--end summary-detail-header-->
|
||||
|
||||
% if c.file.is_submodule():
|
||||
<span class="submodule-dir">Submodule ${h.escape(c.file.name)}</span>
|
||||
% elif c.file.is_dir():
|
||||
% if c.file.is_dir() or c.file.is_submodule():
|
||||
<%include file='files_tree_header.mako'/>
|
||||
% else:
|
||||
<%include file='files_source_header.mako'/>
|
||||
% endif
|
||||
|
||||
</div> <!--end summary-detail-->
|
||||
% if c.file.is_dir():
|
||||
|
||||
% if c.file.is_dir() or c.file.is_submodule():
|
||||
<%include file='files_browser.mako'/>
|
||||
% else:
|
||||
<%include file='files_source.mako'/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue