jw.pkg.cmds.projects.CmdListRepos: Beautify logging

list-repos tries /users/ and /orgs/ to find a working repo URL in a
Forgejo instance, logs a failure and doesn't log anything if it finds
one that works. In the context, that can be mildly confusing,
beautify the output somewhat.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-27 17:05:31 +01:00
commit 956235276a

View file

@ -62,6 +62,7 @@ class CmdListRepos(Cmd): # export
if re.match(r'https://', args.base_url):
# assume Forgejo / Gitea Backend
curl_args = ['-f']
tried: list[str] = []
if password is not None:
assert username is not None
cmd_input = (f'-u {username}:{password}').encode('utf-8')
@ -69,15 +70,15 @@ class CmdListRepos(Cmd): # export
for entities_dir in ['orgs', 'users']:
api_url = f'{args.base_url}/api/v1/{entities_dir}/{args.from_user}/repos'
try:
tried.append(api_url)
repos = await run_curl(curl_args + [api_url], cmd_input=cmd_input)
for repo in repos:
print(repo['name'])
break
except Exception as e:
log(DEBUG, f'No data from {api_url} ({str(e)})')
pass
else:
raise RuntimeError(f'Failed to fetch repository list from assumed Forgejo instance at {args.base_url}')
raise RuntimeError(f'Failed to fetch repository list from assumed Forgejo instance at {args.base_url}, tried {', '.join(tried)}')
return
if os.path.isdir(args.base_url):
for subdir in ["." , args.from_user]: