mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 17:45:55 +02:00
cmds.projects.CmdListRepos: Try Forgejo users and orgs
A "username" in jw-pkg terms, as in $(CLONE_FROM_USER), is not sufficient to identify a remote API URL on a Forgejo server, it can denote both an organization and a user, so try organizations first, then users, and stop on the first occasion found. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
b8e8ecf2f1
commit
26bfda109c
1 changed files with 11 additions and 6 deletions
|
|
@ -66,12 +66,17 @@ class CmdListRepos(Cmd): # export
|
||||||
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')
|
||||||
curl_args.extend(['-K-'])
|
curl_args.extend(['-K-'])
|
||||||
curl_args.extend([
|
for entities_dir in ['orgs', 'users']:
|
||||||
f'https://{url.hostname}/code/api/v1/orgs/{args.from_user}/repos'
|
api_url = f'https://{url.hostname}/code/api/v1/{entities_dir}/{args.from_user}/repos'
|
||||||
])
|
try:
|
||||||
repos = await run_curl(curl_args, 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
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f'Failed to fetch repository list from assumed Forgejo instance at {args.base_url}')
|
||||||
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