mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
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:
parent
afc77ab61d
commit
956235276a
1 changed files with 3 additions and 2 deletions
|
|
@ -62,6 +62,7 @@ class CmdListRepos(Cmd): # export
|
||||||
if re.match(r'https://', args.base_url):
|
if re.match(r'https://', args.base_url):
|
||||||
# assume Forgejo / Gitea Backend
|
# assume Forgejo / Gitea Backend
|
||||||
curl_args = ['-f']
|
curl_args = ['-f']
|
||||||
|
tried: list[str] = []
|
||||||
if password is not None:
|
if password is not None:
|
||||||
assert username is not None
|
assert username is not None
|
||||||
cmd_input = (f'-u {username}:{password}').encode('utf-8')
|
cmd_input = (f'-u {username}:{password}').encode('utf-8')
|
||||||
|
|
@ -69,15 +70,15 @@ class CmdListRepos(Cmd): # export
|
||||||
for entities_dir in ['orgs', 'users']:
|
for entities_dir in ['orgs', 'users']:
|
||||||
api_url = f'{args.base_url}/api/v1/{entities_dir}/{args.from_user}/repos'
|
api_url = f'{args.base_url}/api/v1/{entities_dir}/{args.from_user}/repos'
|
||||||
try:
|
try:
|
||||||
|
tried.append(api_url)
|
||||||
repos = await run_curl(curl_args + [api_url], cmd_input=cmd_input)
|
repos = await run_curl(curl_args + [api_url], cmd_input=cmd_input)
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
print(repo['name'])
|
print(repo['name'])
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log(DEBUG, f'No data from {api_url} ({str(e)})')
|
|
||||||
pass
|
pass
|
||||||
else:
|
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
|
return
|
||||||
if os.path.isdir(args.base_url):
|
if os.path.isdir(args.base_url):
|
||||||
for subdir in ["." , args.from_user]:
|
for subdir in ["." , args.from_user]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue