query/web/api: support getting latest-rc
We support URLs like "/linux/latest/source" that redirect to the latest tagged version. But this excludes release candidates. Add a "latest-rc" that takes RCs into account. Requested by Luca. Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
This commit is contained in:
parent
f260bb555e
commit
acf60d4136
4 changed files with 23 additions and 14 deletions
|
|
@ -43,8 +43,9 @@ class ApiIdentGetterResource:
|
||||||
resp.status = falcon.HTTP_NOT_FOUND
|
resp.status = falcon.HTTP_NOT_FOUND
|
||||||
return
|
return
|
||||||
|
|
||||||
if version == 'latest':
|
if version in ('latest', 'latest-rc'):
|
||||||
version = query.get_latest_tag()
|
rc = version == 'latest-rc'
|
||||||
|
version = query.get_latest_tag(rc=rc)
|
||||||
|
|
||||||
symbol_definitions, symbol_references, symbol_doccomments, _ = query.search_ident(version, ident, family)
|
symbol_definitions, symbol_references, symbol_doccomments, _ = query.search_ident(version, ident, family)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,8 +185,11 @@ class Query:
|
||||||
|
|
||||||
# Returns the latest tag that is included in the database.
|
# Returns the latest tag that is included in the database.
|
||||||
# This excludes release candidates.
|
# This excludes release candidates.
|
||||||
def get_latest_tag(self):
|
def get_latest_tag(self, rc):
|
||||||
sorted_tags = self.scriptLines('get-latest-tags')
|
if rc:
|
||||||
|
sorted_tags = reversed(self.scriptLines('list-tags'))
|
||||||
|
else:
|
||||||
|
sorted_tags = self.scriptLines('get-latest-tags')
|
||||||
|
|
||||||
for tag in sorted_tags:
|
for tag in sorted_tags:
|
||||||
if self.db.vers.exists(tag):
|
if self.db.vers.exists(tag):
|
||||||
|
|
|
||||||
|
|
@ -234,8 +234,9 @@ class SourceResource:
|
||||||
raise ElixirProjectError('Error', 'Path contains characters that are not allowed',
|
raise ElixirProjectError('Error', 'Path contains characters that are not allowed',
|
||||||
project=project, version=version, query=query)
|
project=project, version=version, query=query)
|
||||||
|
|
||||||
if version == 'latest':
|
if version in ('latest', 'latest-rc'):
|
||||||
version = query.get_latest_tag()
|
rc = version == 'latest-rc'
|
||||||
|
version = query.get_latest_tag(rc=rc)
|
||||||
resp.status = falcon.HTTP_FOUND
|
resp.status = falcon.HTTP_FOUND
|
||||||
resp.location = stringify_source_path(project, version, path)
|
resp.location = stringify_source_path(project, version, path)
|
||||||
return
|
return
|
||||||
|
|
@ -333,8 +334,9 @@ class IdentResource(IdentPostRedirectResource):
|
||||||
|
|
||||||
ident = validated_ident
|
ident = validated_ident
|
||||||
|
|
||||||
if version == 'latest':
|
if version in ('latest', 'latest-rc'):
|
||||||
version = query.get_latest_tag()
|
rc = version == 'latest-rc'
|
||||||
|
version = query.get_latest_tag(rc=rc)
|
||||||
resp.status = falcon.HTTP_FOUND
|
resp.status = falcon.HTTP_FOUND
|
||||||
resp.location = stringify_ident_path(project, version, family, ident)
|
resp.location = stringify_ident_path(project, version, family, ident)
|
||||||
return
|
return
|
||||||
|
|
@ -361,8 +363,9 @@ class IncompleteURLRedirectResource:
|
||||||
raise ElixirProjectError('Error', f'Unknown default project: {project}',
|
raise ElixirProjectError('Error', f'Unknown default project: {project}',
|
||||||
status=falcon.HTTP_INTERNAL_SERVER_ERROR)
|
status=falcon.HTTP_INTERNAL_SERVER_ERROR)
|
||||||
|
|
||||||
if version == 'latest' or len(version) == 0:
|
if version in ('latest', 'latest-rc') or len(version) == 0:
|
||||||
version = query.get_latest_tag()
|
rc = version == 'latest-rc'
|
||||||
|
version = query.get_latest_tag(rc=rc)
|
||||||
|
|
||||||
resp.status = falcon.HTTP_FOUND
|
resp.status = falcon.HTTP_FOUND
|
||||||
resp.location = stringify_source_path(project, version, '/')
|
resp.location = stringify_source_path(project, version, '/')
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,16 @@ def init_query(project):
|
||||||
|
|
||||||
|
|
||||||
def get_ident(query, ident, version):
|
def get_ident(query, ident, version):
|
||||||
if version == 'latest':
|
if version == ('latest', 'latest-rc'):
|
||||||
version = query.get_latest_tag()
|
rc = version == 'latest'
|
||||||
|
version = query.get_latest_tag(rc=rc)
|
||||||
|
|
||||||
return query.search_ident(version, ident[0], ident[1])
|
return query.search_ident(version, ident[0], ident[1])
|
||||||
|
|
||||||
def get_file(query, path, version):
|
def get_file(query, path, version):
|
||||||
if version == 'latest':
|
if version == ('latest', 'latest-rc'):
|
||||||
version = query.get_latest_tag()
|
rc = version == 'latest'
|
||||||
|
version = query.get_latest_tag(rc=rc)
|
||||||
|
|
||||||
return query.get_file(version, path)
|
return query.get_file(version, path)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue