jw.pkg.cmds.projects.CmdListRepos: --from-owner

Rename the --from-user option to --from-owner. Forgejo supports users
and organizations under the more general term "owner", so that's the
better term.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-27 17:10:50 +01:00
commit 8dcaa1a6a1
2 changed files with 6 additions and 6 deletions

View file

@ -184,7 +184,7 @@ cmd_get()
[ "$from_user" ] || from_user=$whoami [ "$from_user" ] || from_user=$whoami
if [ -z "$projects" ]; then if [ -z "$projects" ]; then
projects=`$jw_projects projects list-repos --from-user $from_user $remote_base` projects=`$jw_projects projects list-repos --from-owner $from_user $remote_base`
[ "$?" != 0 ] && exit 1 [ "$?" != 0 ] && exit 1
fi fi

View file

@ -18,7 +18,7 @@ class CmdListRepos(Cmd): # export
parser.add_argument('base_url', help='Base URL of all Git repositories without user part') parser.add_argument('base_url', help='Base URL of all Git repositories without user part')
parser.add_argument('--username', help='Username for SSH or HTTP authentication, don\'t specify for unauthenticated', default=None) parser.add_argument('--username', help='Username for SSH or HTTP authentication, don\'t specify for unauthenticated', default=None)
parser.add_argument('--askpass', help='Program to echo password for SSH or HTTP authentication, don\'t specify for unauthenticated', default=None) parser.add_argument('--askpass', help='Program to echo password for SSH or HTTP authentication, don\'t specify for unauthenticated', default=None)
parser.add_argument('--from-user', help='List from-user\'s projects', default='janware') parser.add_argument('--from-owner', help='List from-owner\'s projects', default='janware')
async def _run(self, args: Namespace) -> None: async def _run(self, args: Namespace) -> None:
@ -38,7 +38,7 @@ class CmdListRepos(Cmd): # export
ssh.set_username(username) ssh.set_username(username)
if password is not None: if password is not None:
ssh.set_password(password) ssh.set_password(password)
cmd = f'/opt/jw-pkg/bin/git-srv-admin.sh -u {args.from_user} -j list-personal-projects' cmd = f'/opt/jw-pkg/bin/git-srv-admin.sh -u {args.from_owner} -j list-personal-projects'
out = await ssh.run_cmd(cmd) out = await ssh.run_cmd(cmd)
print(out) print(out)
return return
@ -54,7 +54,7 @@ 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.append(f'https://api.github.com/users/{args.from_user}/repos') curl_args.append(f'https://api.github.com/users/{args.from_owner}/repos')
repos = await run_curl(curl_args, cmd_input=cmd_input) repos = await run_curl(curl_args, cmd_input=cmd_input)
for repo in repos: for repo in repos:
print(repo['name']) print(repo['name'])
@ -68,7 +68,7 @@ class CmdListRepos(Cmd): # export
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-'])
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_owner}/repos'
try: try:
tried.append(api_url) 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)
@ -81,7 +81,7 @@ class CmdListRepos(Cmd): # export
raise RuntimeError(f'Failed to fetch repository list from assumed Forgejo instance at {args.base_url}, tried {', '.join(tried)}') 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_owner]:
out = [] out = []
for entry in os.scandir(args.base_url + "/" + subdir): for entry in os.scandir(args.base_url + "/" + subdir):
path = entry.path path = entry.path