build.cmds.CmdListRepos: Support local repos

Make jw-projects.py list-repos support a local directory as base URL
of all git repositories, notably used by PROJECTS_DIR_REMOTE_BASE,
which can now point to a local directory.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-14 13:17:10 +01:00
commit fa1f1f8b92
3 changed files with 18 additions and 2 deletions

View file

@ -35,7 +35,7 @@ build = realpath
build = realpath build = realpath
[pkg.requires.suse] [pkg.requires.suse]
run = python3 run = python3, python3-GitPython
release = rpmbuild, pkg-config, python3-base release = rpmbuild, pkg-config, python3-base
[pkg.requires.debian] [pkg.requires.debian]

View file

@ -35,6 +35,8 @@ else ifneq ($(findstring ssh://git.janware.com,$(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using janware SSH: $(PROJECTS_DIR_REMOTE_BASE)) $(warning Using janware SSH: $(PROJECTS_DIR_REMOTE_BASE))
else ifneq ($(findstring https://,$(PROJECTS_DIR_REMOTE_BASE)),) else ifneq ($(findstring https://,$(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using HTTPS: $(PROJECTS_DIR_REMOTE_BASE)) $(warning Using HTTPS: $(PROJECTS_DIR_REMOTE_BASE))
else ifneq ($(wildcard $(PROJECTS_DIR_REMOTE_BASE)),)
$(warning Using local PROJECTS_DIR_REMOTE_BASE = $(PROJECTS_DIR_REMOTE_BASE))
else else
$(error Unsupported PROJECTS_DIR_REMOTE_BASE="$(PROJECTS_DIR_REMOTE_BASE)") $(error Unsupported PROJECTS_DIR_REMOTE_BASE="$(PROJECTS_DIR_REMOTE_BASE)")
endif endif

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re, git, os
from argparse import Namespace, ArgumentParser from argparse import Namespace, ArgumentParser
from ..Cmd import Cmd from ..Cmd import Cmd
@ -74,4 +74,18 @@ class CmdListRepos(Cmd): # export
for repo in repos: for repo in repos:
print(repo['name']) print(repo['name'])
return return
if os.path.isdir(args.base_url):
for subdir in ["." , args.from_user]:
out = []
for entry in os.scandir(args.base_url + "/" + subdir):
path = entry.path
try:
_ = git.Repo(path).git_dir
except:
continue
out.append(path)
if out:
print('\n'.join(out))
break
return
raise Exception(f'Don\'t know how to enumerate Git repos at base url {args.base_url}') raise Exception(f'Don\'t know how to enumerate Git repos at base url {args.base_url}')