diff --git a/http/template-head b/http/template-head
index b5ae111..da395ef 100644
--- a/http/template-head
+++ b/http/template-head
@@ -18,7 +18,7 @@
-
Version: $vvar $versions
+
Version: $vvar2 $versions
$banner
diff --git a/http/web.py b/http/web.py
index f35365d..70ca429 100755
--- a/http/web.py
+++ b/http/web.py
@@ -64,7 +64,7 @@ if m:
if not (project and search ('^[A-Za-z0-9-]+$', project)) \
or not (version and search ('^[A-Za-z0-9._-]+$', version)):
status = 302
- location = '/linux/v4.10/'+cmd+arg
+ location = '/linux/latest/'+cmd+arg
cmd = ''
if cmd == 'source':
path = arg
@@ -107,14 +107,20 @@ elif status == 404:
realprint ('Status: 404 Not Found\n')
exit()
-head = open ('template-head').read()
-head = sub ('\$baseurl', 'http://' + os.environ['HTTP_HOST'] + '/' + project + '/', head)
-head = sub ('\$vvar', version, head)
-
basedir = os.environ['LXR_PROJ_DIR']
os.environ['LXR_DATA_DIR'] = basedir + '/' + project + '/data';
os.environ['LXR_REPO_DIR'] = basedir + '/' + project + '/repo';
+if version == 'latest':
+ version2 = shell_exec ('cd ..; ./query.py latest')[0]
+else:
+ version2 = version
+
+head = open ('template-head').read()
+head = sub ('\$baseurl', 'http://' + os.environ['HTTP_HOST'] + '/' + project + '/', head)
+head = sub ('\$vvar2', version2, head)
+head = sub ('\$vvar', version, head)
+
lines = shell_exec ('cd ..; ./query.py versions')
va = OrderedDict()
for l in lines:
@@ -164,13 +170,13 @@ if mode == 'source':
lines = ['null - -']
- type = shell_exec ('cd ..; ./query.py type '+version+' \''+path+'\'')
+ type = shell_exec ('cd ..; ./query.py type '+version2+' \''+path+'\'')
if len (type) == 1:
type = type[0]
if type == 'tree':
- lines += shell_exec ('cd ..; ./query.py dir '+version+' \''+path+'\'')
+ lines += shell_exec ('cd ..; ./query.py dir '+version2+' \''+path+'\'')
elif type == 'blob':
- lines += shell_exec ('cd ..; ./query.py file '+version+' \''+path+'\'')
+ lines += shell_exec ('cd ..; ./query.py file '+version2+' \''+path+'\'')
else:
print ('
This file does not exist.')
status = 404
@@ -247,7 +253,7 @@ elif mode == 'ident':
head = sub ('\$title', project+' identifier search "'+ident+'" - Elixir Cross Referencer - Free Electrons', head)
print (head, end='')
- lines = shell_exec ('cd .. ; ./query.py ident '+version+" '"+ident+"'")
+ lines = shell_exec ('cd .. ; ./query.py ident '+version2+" '"+ident+"'")
lines = iter (lines)
m = search ('Defined in (\d*) file', next (lines))
diff --git a/query.py b/query.py
index e22e74d..a7e8dd6 100755
--- a/query.py
+++ b/query.py
@@ -39,6 +39,10 @@ if cmd == 'versions':
if db.vers.exists (p.split(b' ')[2]):
echo (p + b'\n')
+elif cmd == 'latest':
+ p = script ('get-latest')
+ echo (p)
+
elif cmd == 'type':
version = argv[2]
path = argv[3]
diff --git a/script.sh b/script.sh
index 824d674..0db6b1c 100755
--- a/script.sh
+++ b/script.sh
@@ -97,6 +97,10 @@ case $cmd in
fi
;;
+ get-latest)
+ git tag | version_dir | grep -v '\-rc' | sort -V | tail -n 1
+ ;;
+
get-type)
v=`echo $1 | version_rev`
git cat-file -t "$v:`denormalize $2`" 2>/dev/null