lib + cmds.projects: Use lib.Uri
Remove the feeble attempts at unifying URI handling, and use class Uri from lib.Uri instead.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
f0eeb14a97
commit
d9746cd20b
8 changed files with 65 additions and 98 deletions
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import re, os
|
||||
from argparse import Namespace, ArgumentParser
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from ...lib.log import *
|
||||
from ...lib.Uri import Uri
|
||||
from ..Cmd import Cmd
|
||||
from ..CmdProjects import CmdProjects
|
||||
|
||||
|
|
@ -39,10 +39,10 @@ class CmdGetAuthInfo(Cmd): # export
|
|||
for line in remotes.splitlines():
|
||||
name, url, typ = re.split(r'\s+', line)
|
||||
if name == 'origin' and typ in ['(pull)', '(fetch)']: # TODO: Use other remotes, too?
|
||||
parsed = urlparse(url)
|
||||
parsed = Uri(url)
|
||||
for key in keys:
|
||||
result[key] = getattr(parsed, key)
|
||||
base = parsed.geturl()
|
||||
base = parsed.to_string
|
||||
base = re.sub(r'/jw-pkg', '', base)
|
||||
base = re.sub(r'/proj$', '', base)
|
||||
base = re.sub(r'/proj$', '', base)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from argparse import Namespace, ArgumentParser
|
|||
|
||||
from ...lib.util import get_username, get_password, run_curl
|
||||
from ...lib.log import *
|
||||
from ...lib.Uri import Uri
|
||||
from ..Cmd import Cmd
|
||||
from ..CmdProjects import CmdProjects
|
||||
|
||||
|
|
@ -22,22 +23,21 @@ class CmdListRepos(Cmd): # export
|
|||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
|
||||
from urllib.parse import urlparse
|
||||
url = urlparse(args.base_url)
|
||||
base_url = Uri(args.base_url)
|
||||
askpass_env=['GIT_ASKPASS', 'SSH_ASKPASS']
|
||||
username = await get_username(args=args, url=args.base_url, askpass_env=askpass_env)
|
||||
password = None
|
||||
if username is not None:
|
||||
password = await get_password(args=args, url=args.base_url, askpass_env=askpass_env)
|
||||
match url.scheme:
|
||||
match base_url.scheme:
|
||||
case 'ssh':
|
||||
if re.match(r'ssh://.*git\.janware\.com/', args.base_url):
|
||||
from jw.pkg.lib.ec.SSHClient import SSHClient, ssh_client
|
||||
ssh = ssh_client(args.base_url, interactive=self.app.interactive, verbose_default=self.app.verbose)
|
||||
if username is not None:
|
||||
ssh.set_username(username)
|
||||
base_url.set_username(username)
|
||||
if password is not None:
|
||||
ssh.set_password(password)
|
||||
base_url.set_password(password)
|
||||
ssh = ssh_client(base_url, interactive=self.app.interactive, verbose_default=self.app.verbose)
|
||||
cmd = ['/opt/jw-pkg/bin/git-srv-admin.sh', '-u', args.from_owner, '-j', 'list-personal-projects']
|
||||
result = await ssh.run(cmd)
|
||||
print('\n'.join(result.stdout.decode().splitlines()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue