✨ git-status-all: allow giving the search path on the cmd line
This commit is contained in:
parent
ba0030d418
commit
de53cc79c2
1 changed files with 29 additions and 15 deletions
|
@ -11,6 +11,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
# TODO config file (and defaults here)
|
# TODO config file (and defaults here)
|
||||||
IGNORES = [
|
IGNORES = [
|
||||||
|
@ -36,19 +38,31 @@ def working_directory(directory: Path):
|
||||||
os.chdir(saved_cwd)
|
os.chdir(saved_cwd)
|
||||||
|
|
||||||
|
|
||||||
for git_directory in git_directories('.'):
|
@click.command
|
||||||
# technically,we could have a different GIT_DIR than ".git", but this script
|
@click.argument('topdirs', nargs=-1)
|
||||||
# assumes ".git".
|
def search_dirty(topdirs):
|
||||||
if git_directory.parts[-1] != ".git":
|
"""Search for dirty git working directories in TOPDIRS"""
|
||||||
continue
|
if len(topdirs) == 0:
|
||||||
work_tree_directory = git_directory.parent
|
topdirs = ["."]
|
||||||
|
|
||||||
with working_directory(work_tree_directory):
|
for topdir in topdirs:
|
||||||
try:
|
for git_directory in git_directories(topdir):
|
||||||
out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT)
|
# technically,we could have a different GIT_DIR than ".git", but this script
|
||||||
if len(out) > 0:
|
# assumes ".git".
|
||||||
print('== {}\n{}'.format(work_tree_directory, out.decode('utf-8')))
|
if git_directory.parts[-1] != ".git":
|
||||||
except subprocess.CalledProcessError as e:
|
continue
|
||||||
print((Fore.RED + 'git status is unhappy with {}' + Fore.RESET)
|
work_tree_directory = git_directory.parent
|
||||||
.format(work_tree_directory))
|
|
||||||
print(e.output)
|
with working_directory(work_tree_directory):
|
||||||
|
try:
|
||||||
|
out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT)
|
||||||
|
if len(out) > 0:
|
||||||
|
print('== {}\n{}'.format(work_tree_directory, out.decode('utf-8')))
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print((Fore.RED + 'git status is unhappy with {}' + Fore.RESET)
|
||||||
|
.format(work_tree_directory))
|
||||||
|
print(e.output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
search_dirty()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue