projects-dir-minimal.mk: Default PROJECTS_DIR_REMOTE_BASE to jw-build's remote

If jw-build is already cloned, infect all other repositories with its
remote via PROJECTS_DIR_REMOTE_BASE.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-11-20 16:54:04 +01:00
commit fc02dad92c
2 changed files with 12 additions and 3 deletions

View file

@ -2,7 +2,6 @@
# SPDX-License-Identifier: LGPL-2.0-only
#
# Makefile for managing multiple software repositories in one tree
#
# (C) Copyright 2001-2025, Jan Lindemann <jan@janware.com>
#
# This is the top-level Makefile for a software build tree organized by
@ -21,7 +20,12 @@ PROJECTS_MAKEFILE_NAME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)
JWBDIR ?= jw-build
ifeq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
PROJECTS_DIR_REMOTE_BASE ?= https://janware.com/code
ifneq ($(wildcard $(JWBDIR)),)
PROJECTS_DIR_REMOTE_BASE := $(shell /usr/bin/python3 $(JWBDIR)/scripts/jw-projects.py -p . get-auth-info --remote-base --only-values)
endif
ifeq ($(PROJECTS_DIR_REMOTE_BASE),)
PROJECTS_DIR_REMOTE_BASE := https://janware.com/code
endif
endif
ifneq ($(findstring ssh://git.janware.com/srv/git,$(PROJECTS_DIR_REMOTE_BASE)),)

View file

@ -17,6 +17,7 @@ class CmdGetAuthInfo(Cmd): # export
parser.add_argument('--only-values', help='Don\'t prefix values by "<field-name>="', action='store_true', default=False)
parser.add_argument('--username', help='Show user name', action='store_true', default=False)
parser.add_argument('--password', help='Show password', action='store_true', default=False)
parser.add_argument('--remote-base', help='Show remote base URL', action='store_true', default=False)
def _run(self, args: Namespace) -> None:
keys = ['username', 'password']
@ -32,10 +33,14 @@ class CmdGetAuthInfo(Cmd): # export
if re.match(r'^\s*$', line):
continue
name, url, typ = re.split(r'\s+', line)
if name == 'origin' and typ == '(push)':
if name == 'origin' and typ == '(pull)': # TODO: Use other remotes, too?
parsed = urlparse(url)
for key in keys:
result[key] = getattr(parsed, key)
base = parsed.geturl()
base = re.sub(r'/jw-build', '', base)
base = re.sub(r'/proj$', '', base)
url['remote-base'] = base
break
# --- Print results