diff --git a/pyproject.toml b/pyproject.toml index fe3d7d4..a3e8a88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = ["setuptools", "wheel"] [tool.black] -line-length = 132 +line-length = 100 [tool.pytest.ini_options] addopts = "-ra -v" diff --git a/src/gitutils/__main__.py b/src/gitutils/__main__.py index b249757..7fe7ed6 100644 --- a/src/gitutils/__main__.py +++ b/src/gitutils/__main__.py @@ -27,7 +27,12 @@ def ActOnChanged(): p = argparse.ArgumentParser() p.add_argument("path", help="root path to search under", nargs="?", default=".") p.add_argument("-p", "--preview", help="web browser preview of localhost", action="store_true") - p.add_argument("--port", help="port of localhost web server (Jekyll: 4000, Hugo: 1313)", type=int, default=1313) + p.add_argument( + "--port", + help="port of localhost web server (Jekyll: 4000, Hugo: 1313)", + type=int, + default=1313, + ) p.add_argument("-v", "--verbose", action="store_true") P = p.parse_args() diff --git a/src/gitutils/branch.py b/src/gitutils/branch.py index e2b1e97..ecd673f 100644 --- a/src/gitutils/branch.py +++ b/src/gitutils/branch.py @@ -41,7 +41,9 @@ async def different_branch(main: T.Sequence[str], path: Path) -> T.Tuple[str, st repo path and branch name """ - proc = await asyncio.create_subprocess_exec(*[GITEXE, "-C", str(path)] + BRANCH_SIMPLE, stdout=asyncio.subprocess.PIPE) + proc = await asyncio.create_subprocess_exec( + *[GITEXE, "-C", str(path)] + BRANCH_SIMPLE, stdout=asyncio.subprocess.PIPE + ) stdout, _ = await proc.communicate() if proc.returncode != 0: logging.error(f"{path.name} return code {proc.returncode} {BRANCH_SIMPLE}") @@ -82,13 +84,20 @@ def branch_switch(path: Path, old_branch: str, new_branch: str): continue cmd = [GITEXE, "-C", str(d)] + BRANCH_SIMPLE - ret = subprocess.run([GITEXE, "-C", str(d)] + SWITCH + [new_branch], stderr=subprocess.PIPE, timeout=10, text=True) + ret = subprocess.run( + [GITEXE, "-C", str(d)] + SWITCH + [new_branch], + stderr=subprocess.PIPE, + timeout=10, + text=True, + ) if ret.returncode != 0: stderr = ret.stderr.strip() if stderr == f"fatal: invalid reference: {new_branch}": continue else: - raise ValueError(f"{d} could not switch to {new_branch} from {old_branch}: {stderr}") + raise ValueError( + f"{d} could not switch to {new_branch} from {old_branch}: {stderr}" + ) print(d.name, old_branch, "=>", new_branch) @@ -98,7 +107,9 @@ def cli(): report on git repos not on the expected branch e.g. 'master' """ - p = argparse.ArgumentParser(description="check for non-default branches, and mass switch branches") + p = argparse.ArgumentParser( + description="check for non-default branches, and mass switch branches" + ) p.add_argument("path", help="path to look under", nargs="?", default="~/code") p.add_argument("-v", "--verbose", action="store_true") p.add_argument("-main", nargs="+", default=["main", "master"], help="name of your main branch") diff --git a/src/gitutils/email.py b/src/gitutils/email.py index 62ae923..f39d5d8 100644 --- a/src/gitutils/email.py +++ b/src/gitutils/email.py @@ -10,7 +10,9 @@ from .git import gitdirs, GITEXE, TIMEOUT -def gitemail(path: Path, exclude: str = None) -> T.Iterator[T.Tuple[Path, T.List[T.Tuple[str, int]]]]: +def gitemail( + path: Path, exclude: str = None +) -> T.Iterator[T.Tuple[Path, T.List[T.Tuple[str, int]]]]: """ returns email addresses of everyone who ever made a Git commit in this repo. @@ -33,7 +35,9 @@ def gitemail(path: Path, exclude: str = None) -> T.Iterator[T.Tuple[Path, T.List for d in gitdirs(path): try: - ret = subprocess.check_output([GITEXE, "-C", str(d), "log", '--pretty="%ce"'], text=True, timeout=TIMEOUT) + ret = subprocess.check_output( + [GITEXE, "-C", str(d), "log", '--pretty="%ce"'], text=True, timeout=TIMEOUT + ) except subprocess.CalledProcessError as e: logging.error(f"{path} {e}") continue diff --git a/src/gitutils/pull.py b/src/gitutils/pull.py index a667bad..347bb95 100644 --- a/src/gitutils/pull.py +++ b/src/gitutils/pull.py @@ -43,7 +43,10 @@ async def fetchpull(mode: str, path: Path) -> Path: cmd = [GITEXE, "-C", str(path), mode] proc = await asyncio.create_subprocess_exec( - *cmd, stdout=subprocess.DEVNULL, stderr=asyncio.subprocess.PIPE, stdin=asyncio.subprocess.DEVNULL + *cmd, + stdout=subprocess.DEVNULL, + stderr=asyncio.subprocess.PIPE, + stdin=asyncio.subprocess.DEVNULL, ) _, stderr = await proc.communicate() diff --git a/src/gitutils/status.py b/src/gitutils/status.py index d36e8df..25952cf 100644 --- a/src/gitutils/status.py +++ b/src/gitutils/status.py @@ -45,7 +45,9 @@ def git_porcelain(path: Path) -> bool: if not path.is_dir(): raise NotADirectoryError(path) - ret = subprocess.run([GITEXE, "-C", str(path)] + C1, stdout=subprocess.PIPE, text=True, timeout=TIMEOUT) + ret = subprocess.run( + [GITEXE, "-C", str(path)] + C1, stdout=subprocess.PIPE, text=True, timeout=TIMEOUT + ) if ret.returncode != 0: logging.error(f"{path.name} return code {ret.returncode} {C1}") return False @@ -67,7 +69,9 @@ async def _git_status(path: Path) -> T.Tuple[str, str]: Git repo local changes """ - proc = await asyncio.create_subprocess_exec(*[GITEXE, "-C", str(path)] + C1, stdout=asyncio.subprocess.PIPE) + proc = await asyncio.create_subprocess_exec( + *[GITEXE, "-C", str(path)] + C1, stdout=asyncio.subprocess.PIPE + ) stdout, _ = await proc.communicate() if proc.returncode != 0: logging.error(f"{path.name} return code {proc.returncode} {C1}") @@ -78,7 +82,9 @@ async def _git_status(path: Path) -> T.Tuple[str, str]: if out: return path.name, out # %% detect committed, but not pushed - proc = await asyncio.create_subprocess_exec(*[GITEXE, "-C", str(path)] + C0, stdout=asyncio.subprocess.PIPE) + proc = await asyncio.create_subprocess_exec( + *[GITEXE, "-C", str(path)] + C0, stdout=asyncio.subprocess.PIPE + ) stdout, _ = await proc.communicate() if proc.returncode != 0: logging.error(f"{path.name} return code {proc.returncode} {C0}")