cgit: Allow url to be optional
Some cgit instances are at a domain's root path so we can build their url directly from their 'instance' parameter. This unifies further the cli to register a lister and the cli to schedule the listed origins from a forge. [1] ``` https://git.kernel.org https://source.codeaurora.org https://git.trueelena.org https://dev.sanctum.geek.nz https://git.trueelena.org https://git.dpkg.org https://anongit.mindrot.org https://git.aurel32.net https://gitweb.gentoo.org https://git.joeyh.name https://git.adrian.geek.nz ``` Refs. swh/devel/swh-lister#4693
This commit is contained in:
parent
19bdeefb14
commit
e91e0bf09c
3 changed files with 30 additions and 8 deletions
|
@ -116,12 +116,14 @@ class Lister(Generic[StateType, PageType]):
|
|||
raise ValueError("Must set the LISTER_NAME attribute on Lister classes")
|
||||
|
||||
self.url: str
|
||||
# lister can be instantiated using directly their 'url' (the default behavior)
|
||||
# or derive their url through an 'instance' (their domain's root path) parameter
|
||||
if url is not None:
|
||||
# Retro-compability with lister already instantiated out of a provided url
|
||||
# direct url instantiation
|
||||
self.url = url
|
||||
elif url is None and instance is not None:
|
||||
# Allow lister to be instantiated simply with their type and instance
|
||||
# (as in their domain like "gitlab.com", "git.garbaye.fr", ...)
|
||||
# Allow instantiation through their instance parameter (domain's root path)
|
||||
# (e.g. "gitlab.com", "git.garbaye.fr", ...)
|
||||
self.url = self.build_url(instance)
|
||||
else:
|
||||
raise ValueError(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue