🎨 git-status-all: reformat using black
This commit is contained in:
parent
c53e894b5a
commit
728a265aa7
1 changed files with 26 additions and 13 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue