Skip to content
Snippets Groups Projects
Commit db3c2a18 authored by Nicolas Dandrimont's avatar Nicolas Dandrimont
Browse files

Add basic support for Gitweb in the cgit lister

parent 1ee549fc
No related branches found
Tags v1.0.0
1 merge request!464Draft: Add basic support for Gitweb in the cgit lister
...@@ -94,9 +94,11 @@ class CGitLister(StatelessLister[Repositories]): ...@@ -94,9 +94,11 @@ class CGitLister(StatelessLister[Repositories]):
page_results = [] page_results = []
for tr in bs_idx.find("div", {"class": "content"}).find_all( for tr in bs_idx.find(
"tr", {"class": ""} "table", {"class": re.compile("(list|project_list)")}
): ).find_all("tr"):
if not tr.find("a"):
continue
repository_link = tr.find("a")["href"] repository_link = tr.find("a")["href"]
repo_url = None repo_url = None
git_url = None git_url = None
...@@ -189,6 +191,13 @@ class CGitLister(StatelessLister[Repositories]): ...@@ -189,6 +191,13 @@ class CGitLister(StatelessLister[Repositories]):
# <link rel='vcs-git' href='https://...' title='...'/> # <link rel='vcs-git' href='https://...' title='...'/>
urls = [x["href"] for x in bs.find_all("a", {"rel": "vcs-git"})] urls = [x["href"] for x in bs.find_all("a", {"rel": "vcs-git"})]
if not urls:
# Try the Gitweb heuristic
urls = [
row.contents[-1].string
for row in bs.find_all("tr", {"class": "metadata_url"})
]
if not urls: if not urls:
logger.debug("No git urls found on %s", repository_url) logger.debug("No git urls found on %s", repository_url)
return None return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment