Adding upstream version 0.12.9.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
3ac0de4543
commit
d01d7be95b
8 changed files with 252 additions and 91 deletions
|
@ -4,7 +4,7 @@ import asyncio
|
|||
import platform
|
||||
from functools import lru_cache, partial
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Coroutine, Union
|
||||
from typing import List, Dict, Coroutine, Union, Iterator
|
||||
|
||||
from . import info
|
||||
from . import common
|
||||
|
@ -60,7 +60,6 @@ def get_groups() -> Dict[str, List[str]]:
|
|||
return groups
|
||||
|
||||
|
||||
|
||||
def get_choices() -> List[Union[str, None]]:
|
||||
"""
|
||||
Return all repo names, group names, and an additional empty list. The empty
|
||||
|
@ -128,6 +127,8 @@ def write_to_groups_file(groups: Dict[str, List[str]], mode: str):
|
|||
def add_repos(repos: Dict[str, str], new_paths: List[str]):
|
||||
"""
|
||||
Write new repo paths to file
|
||||
|
||||
@param repos: name -> path
|
||||
"""
|
||||
existing_paths = set(repos.values())
|
||||
new_paths = set(os.path.abspath(p) for p in new_paths if is_git(p))
|
||||
|
@ -142,6 +143,15 @@ def add_repos(repos: Dict[str, str], new_paths: List[str]):
|
|||
print('No new repos found!')
|
||||
|
||||
|
||||
def parse_clone_config(fname: str) -> Iterator[List[str]]:
|
||||
"""
|
||||
Return the url, name, and path of all repos in `fname`.
|
||||
"""
|
||||
with open(fname) as f:
|
||||
for line in f:
|
||||
yield line.strip().split(',')
|
||||
|
||||
|
||||
async def run_async(repo_name: str, path: str, cmds: List[str]) -> Union[None, str]:
|
||||
"""
|
||||
Run `cmds` asynchronously in `path` directory. Return the `path` if
|
||||
|
@ -157,7 +167,7 @@ async def run_async(repo_name: str, path: str, cmds: List[str]) -> Union[None, s
|
|||
stdout, stderr = await process.communicate()
|
||||
for pipe in (stdout, stderr):
|
||||
if pipe:
|
||||
print(format_output(pipe.decode(), f'{repo_name}: '))
|
||||
print(format_output(pipe.decode(), repo_name))
|
||||
# The existence of stderr is not good indicator since git sometimes write
|
||||
# to stderr even if the execution is successful, e.g. git fetch
|
||||
if process.returncode != 0:
|
||||
|
@ -168,7 +178,7 @@ def format_output(s: str, prefix: str):
|
|||
"""
|
||||
Prepends every line in given string with the given prefix.
|
||||
"""
|
||||
return ''.join([f'{prefix}{line}' for line in s.splitlines(keepends=True)])
|
||||
return ''.join([f'{prefix}: {line}' for line in s.splitlines(keepends=True)])
|
||||
|
||||
|
||||
def exec_async_tasks(tasks: List[Coroutine]) -> List[Union[None, str]]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue