mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
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:
parent
50a19954b4
commit
fa1f1f8b92
3 changed files with 18 additions and 2 deletions
|
|
@ -35,7 +35,7 @@ build = realpath
|
|||
build = realpath
|
||||
|
||||
[pkg.requires.suse]
|
||||
run = python3
|
||||
run = python3, python3-GitPython
|
||||
release = rpmbuild, pkg-config, python3-base
|
||||
|
||||
[pkg.requires.debian]
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ else ifneq ($(findstring ssh://git.janware.com,$(PROJECTS_DIR_REMOTE_BASE)),)
|
|||
$(warning Using janware SSH: $(PROJECTS_DIR_REMOTE_BASE))
|
||||
else ifneq ($(findstring 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
|
||||
$(error Unsupported PROJECTS_DIR_REMOTE_BASE="$(PROJECTS_DIR_REMOTE_BASE)")
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import re, git, os
|
||||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from ..Cmd import Cmd
|
||||
|
|
@ -74,4 +74,18 @@ class CmdListRepos(Cmd): # export
|
|||
for repo in repos:
|
||||
print(repo['name'])
|
||||
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}')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue