🎨 git-status-all: reformat using black

master
neingeist 3 months ago
parent c53e894b5a
commit 728a265aa7

@ -16,9 +16,9 @@ import click
# TODO config file (and defaults here) # TODO config file (and defaults here)
IGNORES = [ IGNORES = [
r"\.sync", r"\.sync",
r"\.git/modules", # XXX check this again r"\.git/modules", # XXX check this again
r"\.local/share/containers/storage", r"\.local/share/containers/storage",
] ]
@ -26,7 +26,7 @@ def git_directories(startdir) -> Path:
for dirpath, dirnames, _ in os.walk(startdir): for dirpath, dirnames, _ in os.walk(startdir):
if any(re.search(ignore, dirpath) for ignore in IGNORES): if any(re.search(ignore, dirpath) for ignore in IGNORES):
continue continue
if set(['info', 'objects', 'refs']).issubset(set(dirnames)): if set(["info", "objects", "refs"]).issubset(set(dirnames)):
yield Path(dirpath) yield Path(dirpath)
@ -39,10 +39,17 @@ def working_directory(directory: Path):
@click.command @click.command
@click.argument('topdirs', nargs=-1, type=click.Path(exists=True, file_okay=False, @click.argument(
path_type=Path)) "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.option(
"-l",
"--list",
"list_",
is_flag=True,
default=False,
help="Just list the dirty directories",
)
def search_dirty(topdirs, list_): def search_dirty(topdirs, list_):
"""Search for dirty git working directories in TOPDIRS""" """Search for dirty git working directories in TOPDIRS"""
if len(topdirs) == 0: if len(topdirs) == 0:
@ -50,7 +57,7 @@ def search_dirty(topdirs, list_):
for topdir in topdirs: for topdir in topdirs:
for git_directory in git_directories(topdir): 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". # assumes ".git".
if git_directory.parts[-1] != ".git": if git_directory.parts[-1] != ".git":
continue continue
@ -61,14 +68,20 @@ def search_dirty(topdirs, list_):
out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT) out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT)
if len(out) > 0: if len(out) > 0:
if not list_: 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: else:
print(work_tree_directory) print(work_tree_directory)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print((Fore.RED + 'git status is unhappy with {}' + Fore.RESET) print(
.format(work_tree_directory)) (
Fore.RED + "git status is unhappy with {}" + Fore.RESET
).format(work_tree_directory)
)
print(e.output) print(e.output)
if __name__ == '__main__': if __name__ == "__main__":
search_dirty() search_dirty()

Loading…
Cancel
Save