From 728a265aa7ebab7f676a26bb30da09934f1f6aad Mon Sep 17 00:00:00 2001 From: neingeist Date: Tue, 6 Feb 2024 23:12:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20git-status-all:=20reformat=20usi?= =?UTF-8?q?ng=20black?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- git-status-all | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/git-status-all b/git-status-all index f2a9f73..0337794 100755 --- a/git-status-all +++ b/git-status-all @@ -16,9 +16,9 @@ import click # TODO config file (and defaults here) IGNORES = [ - r"\.sync", - r"\.git/modules", # XXX check this again - r"\.local/share/containers/storage", + r"\.sync", + r"\.git/modules", # XXX check this again + r"\.local/share/containers/storage", ] @@ -26,7 +26,7 @@ def git_directories(startdir) -> Path: for dirpath, dirnames, _ in os.walk(startdir): if any(re.search(ignore, dirpath) for ignore in IGNORES): continue - if set(['info', 'objects', 'refs']).issubset(set(dirnames)): + if set(["info", "objects", "refs"]).issubset(set(dirnames)): yield Path(dirpath) @@ -39,10 +39,17 @@ def working_directory(directory: Path): @click.command -@click.argument('topdirs', nargs=-1, type=click.Path(exists=True, file_okay=False, - path_type=Path)) -@click.option('-l', '--list', 'list_', is_flag=True, default=False, - help='Just list the dirty directories') +@click.argument( + "topdirs", nargs=-1, type=click.Path(exists=True, file_okay=False, path_type=Path) +) +@click.option( + "-l", + "--list", + "list_", + is_flag=True, + default=False, + help="Just list the dirty directories", +) def search_dirty(topdirs, list_): """Search for dirty git working directories in TOPDIRS""" if len(topdirs) == 0: @@ -50,7 +57,7 @@ def search_dirty(topdirs, list_): for topdir in topdirs: for git_directory in git_directories(topdir): - # technically,we could have a different GIT_DIR than ".git", but this script + # technically, we could have a different GIT_DIR than ".git", but this script # assumes ".git". if git_directory.parts[-1] != ".git": continue @@ -61,14 +68,20 @@ def search_dirty(topdirs, list_): out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT) if len(out) > 0: if not list_: - print('== {}\n{}'.format(work_tree_directory, out.decode('utf-8'))) + print( + f"== {work_tree_directory}\n" + f"{out.decode("utf-8")}" + ) else: print(work_tree_directory) except subprocess.CalledProcessError as e: - print((Fore.RED + 'git status is unhappy with {}' + Fore.RESET) - .format(work_tree_directory)) + print( + ( + Fore.RED + "git status is unhappy with {}" + Fore.RESET + ).format(work_tree_directory) + ) print(e.output) -if __name__ == '__main__': +if __name__ == "__main__": search_dirty()