Merge pull request #126 from MaximeChretien/symlinks

Handle symlinks in tree view instead of creating a link inside
This commit is contained in:
Michael Opdenacker 2020-05-19 10:32:34 +02:00 committed by GitHub
commit 3437499342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 37 deletions

View file

@ -8,7 +8,6 @@ exec(open('makefiledir.py').read())
exec(open('makefilefile.py').read())
exec(open('makefilesubdir.py').read())
exec(open('makefilesrctree.py').read())
exec(open('symlinks.py').read())
exec(open('cpppathinc.py').read())
# include/uapi contains includes to user headers under #ifndef __KERNEL__

View file

@ -1,32 +0,0 @@
# Filter for symbolic links
symlinks = []
def keep_symlinks(m):
dir_name = os.path.dirname(path)
rel_path = m.group(1)
if dir_name != '/':
dir_name += '/'
full_path = os.path.abspath(dir_name + rel_path)
if query('exist', tag, full_path):
symlinks.append((full_path, rel_path))
return '__KEEPSYMLINKS__' + encode_number(len(symlinks)) + m.group(2)
else:
return m.group(0)
def replace_symlinks(m):
w, n = symlinks[decode_number(m.group(1)) - 1]
return '<a href="'+version+'/source'+w+'">'+n+'</a>'
symlinks_filters = {
'case': 'any',
'prerex': '((?:\.\./)+[-\w/]+/[-\w\.]+)(\s+|$)',
'prefunc': keep_symlinks,
'postrex': '__KEEPSYMLINKS__([A-J]+)',
'postfunc': replace_symlinks
}
filters.append(symlinks_filters)

View file

@ -186,7 +186,7 @@ if mode == 'source':
else path_split[-1]+' - '+'/'.join(path_split)+' - ') \
+title_suffix
lines = ['null - -']
lines = ['null - - -']
type = query('type', tag, path)
if len(type) > 0:
@ -200,12 +200,12 @@ if mode == 'source':
if type == 'tree':
if path != '':
lines[0] = 'back - -'
lines[0] = 'back - - -'
print('<div class="lxrtree">')
print('<table><tbody>\n')
for l in lines:
type, name, size = l.split(' ')
type, name, size, perm = l.split(' ')
if type == 'null':
continue
@ -216,6 +216,19 @@ if mode == 'source':
elif type == 'blob':
size = size+' bytes'
path2 = path+'/'+name
if perm == '120000':
# 120000 permission means it's a symlink
# So we need to handle that correctly
dir_name = os.path.dirname(path)
rel_path = query('file', tag, path2)
if dir_name != '/':
dir_name += '/'
path2 = os.path.abspath(dir_name + rel_path)
name = name + ' -> ' + path2
elif type == 'back':
size = ''
path2 = os.path.dirname(path[:-1])

View file

@ -87,7 +87,7 @@ get_dir()
{
v=`echo $opt1 | version_rev`
git ls-tree -l "$v:`denormalize $opt2`" 2>/dev/null |
awk '{print $2" "$5" "$4}' |
awk '{print $2" "$5" "$4" "$1}' |
grep -v ' \.' |
sort -t ' ' -k 1,1r -k 2,2
}